We can push event handling to the message queue module to not care about the event it fires in the consumer module. Also move the async stuff to the message queue module.
function consumer() {}
MessageQueue.subscribe(consumer)
function consumerAsync() {}
MessageQueue.subscribeAsync(consumer[, data[, parallelLimit]])
First argument is the function name of the consumer and second optional argument is the event it subscribes to. When the second argument is not given, consumer should be subscribed to all possible events. If a message queue handles only one channel, this is pretty self-explanatory.
When calling consumerAsync the async module is used to handle parallel execution of consumerAsync(). Wording might change to subscribeParallel().
In both cases the consumer function is called like this: consumer(eventData, 'eventName')
Be careful not to call each subscriber with different eventDara because of MessageQueue.first(). On each event, all subscribers must be called with the exact same parameters.
We can push event handling to the message queue module to not care about the event it fires in the consumer module. Also move the async stuff to the message queue module.
First argument is the function name of the consumer and second optional argument is the event it subscribes to. When the second argument is not given, consumer should be subscribed to all possible events. If a message queue handles only one channel, this is pretty self-explanatory.
When calling
consumerAsynctheasyncmodule is used to handle parallel execution ofconsumerAsync(). Wording might change tosubscribeParallel().In both cases the consumer function is called like this:
consumer(eventData, 'eventName')Be careful not to call each subscriber with different
eventDarabecause ofMessageQueue.first(). On each event, all subscribers must be called with the exact same parameters.