Wednesday, March 28, 2012

Receive all messages on queue

Hi i am trying to create a batch process then commit for all messages on the queue. The problem i am having is when i run my query (As below) I only receive the first message and the corresponding end dialog for the message although i have 2000 records sitting in the queue. It is my understanding that receive without any criteria i.e top(1) or where clause should select everything of the queue. I tried receive top(100) expecting 100 records but still only got 2 back.

any help appreciated.

WAITFOR(RECEIVE

queuing_order,

conversation_handle,

message_type_name,

message_body

FROM [RMIS_COMMS_Queue]

INTO @.tableMessages), TIMEOUT 2000;

Each RECEIVE returns only messages belonging to conversation in one conversation group only. If each conversation is its own group (which is true unless you use RELATED_CONVERSATION clause in BEGIN DIALOG or you use MOVE CONVERSATION) then it means you can RECEIVE only one conversation in one call. The TOP clause applies to this resultset (one conversation).

HTH,
~ Remus

|||Thanks for that. Can i just refer to your article on batch processing messages (the example with the cursor) this is the method i am try ing to implement but my scenario is many shops with many tills, where each message/conversation is a complete sale from a till i.e many conversations with one message. Is it safe to say this is not the best method for trying to speed this up, what would be the best way to process these messages, bearing in mind sometimes a shop can lose comms and send down a batch of sales when it reconnects.|||

I'm using triggers to cause an update of a seperate database via service broker, in our activated stored procedure we are seeing similiar situations, Could you give an example of a script that a trigger might use to take advantage of the RELATED_CONVERSATION clause? I looked at the documentation and didn't see how I could use this in our situation. (trigger on update sends inserted table with for xml clause as message to queue)

Thanks,

Bill

No comments:

Post a Comment