Service Broker receives only one message at a time

Even when I specify Receive Top (25), etc., I get only one message that needs to be deleted in turn. Not sure what I am doing wrong inside my sproc? Probably something trivial, but I do not see a problem.

Sproc:

CREATE PROCEDURE dbo.SPP_DEQUEUE_MESSAGE

AS

BEGIN

DECLARE @receiveTable TABLE(
message_type        sysname,
message_body        xml,
message_dialog      uniqueidentifier);

    BEGIN TRANSACTION;

    WAITFOR
        ( RECEIVE TOP(25)
            message_type_name,
            message_body,
            conversation_handle  
          FROM TargetQueue1DB
            INTO @receiveTable
        ), TIMEOUT 3000;

    SELECT 
        *
    From @receiveTable;     

    Delete from @receiveTable;

COMMIT TRANSACTION;

END --End Sproc

Any idea what I'm doing wrong?

Thank,

AT

+3
source share
2 answers

I assume that each message refers to a different conversation (and therefore, by default, to a different conversation group). If so, then this is the expected behavior.

From Email to Books - Receive (Transact-SQL) :

, RECEIVE

, .

+5

, , proc?

,

SELECT sq.name,   p.rows FROM sys.service_queues sq    sys.internal_tables it ON sq.object_id = it.parent_id        it.parent_minor_id = 0        it.internal_type = 201    sys.indexes i.object_id = it.object_id i.index_id = 1    sys.partitions p p.object_id = i.object_id p.index_id = i.index_id   sq.object_id = it.parent_id AND   it.parent_minor_id = 0   it.internal_type = 201

1 , 1 .

0

Source: https://habr.com/ru/post/1780525/


All Articles