SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Execute long-running updates using Service Broker activation


Execute long-running updates using Service Broker activation

Author
Message
Mansfield
Mansfield
SSChasing Mays
SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)

Group: General Forum Members
Points: 660 Visits: 394
Hello,

A typical Service Broker activation procedure is structured something like this:

begin transaction
waitfor receive
do something
end conversation
commit transaction



In my case the "do something" is a batched, very long-running stored procedure which will hold locks etc. The process is designed to be resumeable and I do not want the entire thing to be run inside a single explicit transaction.

What ways are there to cope with this situation - to run the payload proc outside the scope of the activation proc transaction without violating the integrity of the "receive + end conversation" unit of work?

Thanks Smile
sturner
sturner
SSCarpal Tunnel
SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)

Group: General Forum Members
Points: 4820 Visits: 3259
What I have done in the past is to have the broker request procedure write a request row to a separate table then send the ID of the row into the broker queue message. Long running or multi-stage transactions can be broken down into steps, having whatever process (or processes) performing the operations updating a status in that row after completion of each phase. That way you can close out the transaction from the activation procedure and keep it short which is what you need to do.

If you can't (or don't want) to do your long running process that way you might consider turning off activation and just executing the activation procedure from and external process (multi-threaded or otherwise).

The probability of survival is inversely proportional to the angle of arrival.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search