Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am reading through SQL server books online for the first team whilst learning how to use the service broker and I came across this statement:

The application that implements the service reads the message, runs the query, and returns the results. All three of these operations take place in the same transaction. If a failure occurs before the transaction commits, the entire transaction rolls back and the message returns to the queue. When the computer recovers, the application restarts and processes the message again.

I am guessing that this will block in the same way as usual transactions? Ie. row/page locks. Am I correct? Is this something that I should worry about or just leave it until I have a problem?

share|improve this question
Oh and could someone with enough rep create a "service-broker" tag please :) Quote from: – Stuart Blackler Aug 22 '11 at 20:50
thanks @gbn :). – Stuart Blackler Aug 22 '11 at 21:30
up vote 2 down vote accepted

When the service broker pulls messages from the queue using an activation stored procedure (or in any method) all the normal locking rules apply to the queue and the objects which are referenced in the code after the receiving of messages from the service broker queue.

Note that the information in BOL that you quoted is only true is you do the receive within an explicitly defined transaction. If you receive a message and there is no explicit transaction to rollback then the database can't put the message back in the queue.

share|improve this answer
thanks for this :) I thought as much, but it was a long session earlier and my brain is quiet functioning as it should ha! – Stuart Blackler Aug 22 '11 at 21:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.