Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Execute long-running updates using Service Broker activation Expand / Collapse
Author
Message
Posted Tuesday, August 13, 2013 9:02 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, July 15, 2014 2:20 PM
Points: 364, Visits: 384
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 :)
Post #1484057
Posted Wednesday, August 21, 2013 1:07 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, June 11, 2014 2:38 PM
Points: 1,426, Visits: 3,223
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.
Post #1486879
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse