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.
string | number | boolean
attributes
await bus.send( new ChargeCreditCard(), { attributes: { ip: '229.40.202.156', 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() .withHandler( ChargeCreditCard, async (_: ChargeCreditCard, { attributes }: MessageAttributes) => console.log(attributes) ) .initialize()
Last updated 3 years ago