Sql Service Broker uses the following heuristics to determine when there are messages in your queue that prevent your application from doing any useful work:
"Service Broker provides automatic detection of poisonous messages. When a transaction containing a RECEIVE statement is returned five times, Service Broker disconnects all the queues from which the transaction was received from messages, automatically setting the queue status to OFF." ( http://msdn.microsoft.com/en-us/library/ms166137.aspx )
I'm fine with this basic approach, but is there a way to change # repetitions from five to something higher, maybe twenty?
The reason I would be useful is because the code I use to process the queue is an application outside of Sql Server, in which there are about 10 worker threads, each of which has an independent SqlConnection and each of which runs it RECEIVE's own independent statements. If this application dies for some reason, it potentially causes a separate rollback transaction for each worker thread, which is enough rollback to turn off the queue. On the contrary, I would like to be able to kill my application without disconnecting the queue. I probably should rewrite the application to use one SqlConnection, but it would be much easier if I could just say something like
ALTER QUEUE MyQueue SET RollbacksBeforePoison=20
Is this possible?
sql-server service-broker
Chris
source share