We have set up basic SQL Service Broker queues and are monitoring activity and we are finding it difficult to understand the messaging count activity.
EventsReceiveQueue receives messages from a source table via a trigger on that table.
EventsSendQueue then forwards the message to an external system for processing.
From our source we can place about 100k messages into the ReceiveQueue in about 1 minute. These messages flow through to the SendQueue quite quickly and the ReceiveQueue drops to a count of 0.
Then the funnny business starts. We can see the messages populating in the external system at a rate of about 1k per minute (the restrictin is the external system, this is known) the strange behaviour, and the reason for this post is that the count of messages stays fairly flat in the SendQueue until all messages reach the destination at which point the count dramatically falls to 0.
In the graph you can see this behaviour at 17:00 hours yesterday and 09:00 this morning.
Can anyone explain why the count of messages does not gradually reduce which is what we expected?
Many thanks,
John
p.s. we are using either 'select count (*) from queuename' or the method described here http://blog.extreme-advice.com/2013/04/10/count-active-thread-for-service-broker-queue-in-sql-server/ to count the records.