Service Broker - Clean up your transmission queue

This isn't about changing your air filter, spark plugs or oil. Its about what to do when, like me, you don't get things right first time.

If developing Service Broker applications and you misspell your services, forget to create a master key, or do any of the many things that result in your messages not being delivered, then your transmission queue will fill up.

Do to the nature of SB errors don't occur at the client but rather your messages go in to the black box and are processed. If they fail they stay in the black box. Some errors can be resolved, i.e. missing services, however others can't (or are more awkward) i.e. you've misspelt something, or not used the correct security.

To clear your transmission queue you need to end the conversations, this is a handy little script for doing this. Be aware this ends ALL conversations in the queue and so should NEVER be used on a production system.

declare @conversation uniqueidentifier

while exists (select 1 from sys.transmission_queue )


set @conversation = (select top 1 conversation_handle from sys.transmission_queue )

end conversation @conversation with cleanup


Published Thursday, September 28, 2006 12:59 PM by simonsabin


Tuesday, October 3, 2006 9:42 PM by Adam Machanic

# re: Service Broker - Clean up your transmission queue

Hi Simon,

Another way to accomplish the same thing is to do:


However, this gives your DB a new broker identifier.  I think that might break some functionality having to do with SSB endpoints, as I recall that something in that stack does require that you register the identifier.  I believe this will not hurt anything if you're not doing endpoints, though.