Comment on page
Lifecycle hooks
@node-ts/bus exposes a number of lifecycle hooks that can be subscribed to. These are EventEmitter instances that follow the standard node
.on()
and .off()
notation.beforeSend
called just before a command is sent to the underlying transport
bus.beforeSend.on(({ command, attributes }) => {})
beforePublish
called just before a event is published to the underlying transport
bus.beforePublish.on(({ event, attributes }) => {})
afterReceive
called after a message has been read from the queue, and before it is dispatched to handlers
bus.afterReceive.on(transportMessage => {})
beforeDispatch
called before a message is dispatched to its handlers
bus.beforeDispatch.on(({ message, attributes, handlers }) => {})
afterDispatch
called after a message has been successfully handled and the message deleted from the transport
bus.afterDispatch.on(({ message, attributes }) => {})
onError
called when an error occurred reading/dispatching/handling a message
bus.onError.on(({ message, error, attributes, rawMessage }) => {})
Last modified 2yr ago