As part of the effort to automate the start / stop of some of our NServiceBus services, I would like to know when the service finished processing all the messages in the input queue.
The problem is that although the NServiceBus service is running, my C # code is reporting one smaller message than it actually is . Therefore, he believes that the queue is empty when another message remains. If the service is stopped, it reports the "correct" number of messages. This is confusing because when I check the queues myself using the Private Queues view in Computer Management, it displays the “correct” number.
I am using a variant of the following C # code to find the number of posts:
var queue = new MessageQueue(path); return queue.GetAllMessages().Length;
I know this will happen terribly when there are a lot of messages. The queues that I check should only have a few messages at a time.
I looked at other questions , but did not find the help I needed.
Any insights or suggestions would be appreciated!
Update:. I should have mentioned that this service is behind the distributor, who disconnects before trying to disable this service. Therefore, I am sure that new messages will not be added to the service entry queue.
source share