August 13, 2013 at 9:02 pm
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 🙂
August 21, 2013 at 1:07 pm
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.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply