On Fri, Dec 30, 2011 at 7:43 PM, Jeff Bester
<jbe...@gmail.com> wrote:
Is there any way using pubsub to guarantee total ordering of topics? By total ordering, I mean if I have two topics (A and B) and one of A's listeners emits topic B then when A is emitted all of A's listeners are invoked prior to any of B's listeners.
See attached for a contrived example
Jeff, the short answer is no, there isn't, pubsub wasn't designed for chaining of messages like this. Some ways to work around this limitation:
- Make the "connected" event a separate step based on a flag set in link driver. Presumably you have some sort of event loop that gives your business objects a chance to "do something" (an update() method, for instance). Your LinkDriver would send message during update() based on a flag set during the last "start" message received.
- You have a message queuer, it listens for all "queue.*" messages and queues them; your event loop gives it a chance to process its queue every so often. So during the reception of "start" message the link driver would emit "queue.connected"; the queuer gets this and queues it; later, the queuer gets its "processQueue()" called by event loop, it will generate "connected" as it goes through its queue.
Oliver