I'm currently looking for a way to decently pauze the processing of messages by activation procedures. When I pauze the processing I want to be sure that the running activation procedures terminated.
I thought I could do this using ALTER QUEUE WITH ACTIVATION (STATUS = OFF) and sys.dm_broker_activated_tasks.
This is what I've tested: I set up one queue with an activation procedure attached to it that receives one message, then waits for one minute, then writes that message into a table. The queues max queue readers is set to 2. Now, I put 5 messages in the queue, 2 procs pop up in sys.dm_broker_activated_tasks. I run the alter queue statement shown above and check sys.dm_broker_activated_tasks again. It is empty so allegedly there are no tasks running. I check the table in which the messages are written by the activation procs and after some time I can see the results of both activation procedures which were according to sys.dm_broker_activated_tasks not running (but of course they were). The rest of the process works as expected, the procs reactivate upon reenabling the activation status and all is well.
Is there another way of checking the running activation procedures that checking sys.dm_broker_activated_tasks?
Is this intended behaviour or just a bug?When you turn off activation, the activation routines stop running on the queue so the dmv's aren't maintained but any processes already running will continue to run until they end themselves. If you really want to prevent messages from being processed, you would be better off making the queue not ready. If you want to keep the queues active and end the activated procedures you will have to kill the activated procedures in addition to turning oss activation.|||Disabling the queue entirely does cause the expected behaviour in dm_broker_activated_tasks. My solution to pauze is now to disable the queue, check dm_broker_activated_tasks and wait for all queue readers to finish, then disable the activation on the queue and reenable the queue itself. Resuming is then as easy as reenabling activation on the queue.
In fact I didn't want to disable the queue because that seems risky to me. Notably, messages will keep on being sent to the disabled queue (because they are delivered whenever an even occurs) but they won't arrive safely in it. Therefore I'm reenabling the queue asap after having disabled it.
Still I think that dm_broker_activated_tasks should remain updated for as long as a queue reader is running.
Thank you,
Kr
R.|||If the queue is disabled, messages will be held in the sys.transmission_queue so there's no loss of reliability and the messages will be transferred to the target queue when it becomes available.
No comments:
Post a Comment