I just wanted to see how other people take care that QMH messages that are meant to be run sequentially only get messages added after them, and not inserted in between them. My curiosity was prompted by several of drjdpowell's posts and videos.
- Perhaps this could be taken care of by being careful of when I enqueue messages, but it's easy to come back to code in a month and forget the careful timing considerations, or to pass it off to a co-worker who is not aware of them, so I would rather this be taken care of by the QMH architecture.
- One choice is to have two queues (or more generally two message streams). One that executes local messages, and another that executes external messages only when there are no more local messages.
The JKI state machine does this where the internal messages are on the states string and the external messages come through the event structure. The DQMH does this where the internal messages are on the queue and the external messages come through the event structure.
- Another choice is to make sure messages are enqueued at only one place at a time using a DVR or Action Engine. I would prefer the DVR route because sometimes I want to enqueue a single message and other times an array of messages, so the action engine would have many inputs.
I hope to hear some thoughts on what considerations you take when working with QMHs. Thank you,
Just came across a great blog post by James McNally which addresses this and other issues. For those interested: