block-quote On this pagechevron-down
copy Copy chevron-down
Guide 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
Copy bus.beforeSend.on(({ command, attributes }) => {}) beforePublish
called just before a event is published to the underlying transport
Copy bus.beforePublish.on(({ event, attributes }) => {}) afterReceive
called after a message has been read from the queue, and before it is dispatched to handlers
Copy bus.afterReceive.on(transportMessage => {}) beforeDispatch
called before a message is dispatched to its handlers
Copy bus.beforeDispatch.on(({ message, attributes, handlers }) => {}) afterDispatch
called after a message has been successfully handled and the message deleted from the transport
Copy bus.afterDispatch.on(({ message, attributes }) => {}) onError
called when an error occurred reading/dispatching/handling a message