Is there a flag on RedisMqServer class that I can set to stop the instance of RedisMqServer picking messages off the queue?
Once a message is picked off the queue it is gone and I am hosting my “ProcessQueue” BasicAppHost within azure webjobs and of course it may get stopped (for example when I switch from staging).
(I would NOT want to stop the ability to publish as that would cause an issue if an executing service thread requires the publishing of another message)
It stops all worker threads so they wont process any new messages, but it wont kill the currently executing background thread. But Starting the MQ Server again will kill any currently executing background thread, before starting a new one.
Are you saying if there are two or more different services executing in background threads only the one that is currently executing will run to completion and the others will be killed? (with async that could be lots killed). Or do you mean one per service can be ‘current’ in your definition?
No I’m saying each worker processing messages will stop processing new messages after calling Stop(), they wont kill the single background that executes the message in each worker, but if Start() was called before the background thread finished executing, it will be killed before start a new background thread for the worker.
Thanks, ideally I would also like to know if all the background threads attached to the workers are done so that I could wait for a little longer if not.
I see there is WorkerThreadsStatus() …perhaps not ideal as it gives string[] with extra other rather than just int[] of the status…but I could just check if each contains ‘stopped’.
Please can you confirm that would indeed tell me the background threads are done (or I misunderstand).
Calling Stop() sets the status to WorkerStatus.Stopping which tells the background thread not to process any more messages. Once the status of the MessageHandler is WorkerStatus.Stopped it means the message worker’s background thread finished.
Calling GetStatus() or GetStats() on each Worker Handler will return the status but the message workers are hard to get to. If you cast to RedisMqServer you can get a text description of the Message worker status with WorkerThreadStatus() which you could check to see if they all contain the string “Stopped”.