This is info that I am still not certain about and I just need to make sure, my gut feeling is correct:
A.
When a procedure is triggered upon reception of a message in a queue, what happens when the procedure fails and rolls back?
1. Message is left on the Queue.
2. is the worker procedure triggered again for the same message by the queue?
3. I am hoping the Queue keeps on triggering workers until it is empty.
My scenario is that my queue reader procedure only reads one message at a time, thus I do not loop to receive many messages.
B.
For my scenario messages are independent and ordering does not matter.
Thus I want to ensure my Queue reader procedures execute simultaneously. Is reading the Top message in one reader somehow blocking the queue for any other reader procedures? I.e. if I have BEGIN TRANSACTION when reading messages of the Queue, is that effectively going prevent many reader procedures working simultaneously. Again, I want to ensure that Service broker is effectively spawning procedures that work simultaneously.
Thank you very much for the time,
LubomirOnly reading one message per invocation will together slow down you application enough so that the other things you're worried about will probably be minor by comparison. As long as there are enough seperate dialogs so that there's at least one dialog per queue read you should see parallelism because a receive only locks one conversation group. If I understand what you're doing you will have one one dialog per conversation group so you will lock on one dialog per transaction.|||
Hello,
A. Service Broker functionality is entirely driven by the normal transactional operations rules of SQL Server. All effects of any Service Broker verbs (BEGIN DIALOG, SEND, RECEIVE, END CONVERSATION etc) will be undone if the transaction is rolled back. So if a queue reder rollsback a RECEIVE, the messages will be back in the queue, available again for activation. Be careful dough, if you activated stored procedure rollsback frequently, you are in danger of triggering poison message detection mechanism. If the activated procedure rollsback the RECEIVE verb result 5 times in a row, the whole queue will be disabled. For details, see http://msdn2.microsoft.com/en-us/library/ms166137.aspx
And yes, queue readers will continue to be activated as long as there are messages in the queue available for receive. Also, queue readers will be activated each time a database comes online, like at server start up.
B. Queue readers can progress in paralel as long as there are multiple conversations available for processing. RECEIVE verb will lock the conversations on which it returned messages, so that no other queue reader processes messages from the same conversation(s). for more details, see the 'Conversation groups' topic in BOL, at http://msdn2.microsoft.com/en-us/library/ms166131(en-US,SQL.90).aspx
HTH,
~ Remus
This makes perfect sense.
Lubomir
No comments:
Post a Comment