Even when I specify Receive Top(25), etc I am only getting one message to be dequeued at a time. Not sure what i am doing wrong inside my sproc? Probably something trivial, but I don't see the 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 am doing wrong?
Thanks,
B
Service Broker provides queuing and reliable messaging for SQL Server. Service Broker is used both for applications that use a single SQL Server instance and applications that distribute work across multiple instances. Within a single SQL Server instance, Service Broker provides a robust asynchronous programming model.
GitHub Repository service - this is designed to be an easy-to-read example of a service broker, with complete documentation, and comes with a demo app that uses the service. The broker can be deployed as an application to any Cloud Foundry instance or hosted elsewhere.
My guess would be that each message belongs to a different conversation (and therefore by default to a different conversation group). If this is the case, then this is expected behavior.
From Books Online - Receive (Transact-SQL):
All messages that are returned by a RECEIVE statement belong the same conversation group
If you want to receive multiple messages at once, send multiple messages on a single conversation or group multiple conversations into a single conversation group on the receiving end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With