Sql Service Broker uses the following heuristic to determine when you have messages in your queue that are preventing your application from doing any useful work:
"Service Broker provides automatic poison message detection. When a transaction that contains a RECEIVE statement rolls back five times, Service Broker disables all queues that the transaction received messages from, by 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 any way to change the # of retries from five to something higher, maybe twenty?
The reason this would be useful to me is that the code I'm currently using to process the queue is an app outside of Sql Server that has around 10 worker threads, each of which has an independent SqlConnection and each of which executes its own independent RECEIVE statements. If this application dies for some reason, this potentially causes a separate rollback transaction for each worker thread, which is enough rollbacks to disable the queue. In contrast, I would like to be able to kill my application without disabling the queue. I should probably rewrite the application to use a single SqlConnection, but it would be a lot easier if I could just say something like
ALTER QUEUE MyQueue SET RollbacksBeforePoison=20
Is anything like that possible?