I have been running a load test that involves a Service Broker queue over night. Something went wrong and the queue ended up with 1.3 million messages in it. I just want to clear these out, no backup and no logging required. The trouble is that when I try to drop the queue it is taking half an hour and then the log file fills up and the whole thing rolls back. Is there a quick and dirty way of flushing everything out the queue?
You can clear all conversations at once with the following statement:
declare @conversationHandle uniqueidentifier
select top 1 @conversationHandle = conversation_handle from sys.conversation_endpoints
while @@rowcount = 1
begin
end conversation @conversationHandle with cleanup
select top 1 @conversationHandle = conversation_handle from sys.conversation_endpoints
end
If you omit the TOP 1 clause in the RECEIVE statement then it will receive all messages that meet the criteria, or setting it to a high number will allow you to clear the backlog in managable chunks.
The trick will be to 'blackhole' the messages so the result set isn't returned to the client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With