Arbitrary attributes can be sent with each message. Attributes support string | number | boolean values. These can be provided by using the attributes property when sending a message.

await bus.send(
  new ChargeCreditCard(),
    attributes: {
      ip: '',
      attempt: 0,
      automatic: true

Attributes can be accessed as the second parameter of the handler.

import { MessageAttributes } from '@node-ts/bus-messages'

await Bus.configure()
    async (_: ChargeCreditCard, { attributes }: MessageAttributes) => console.log(attributes)

Last updated