For the complete documentation index, see llms.txt. This page is also available as Markdown.

Sticky attributes

Sticky attributes are similar to regular attributes except they will be copied to any message immediately or subsequently sent as a result of the original message being processed.

These can be sent by specifying a value for stickyAttributes

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

Sticky attributes can be accessed using the stickyAttribtues of the second parameter of a handler.

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

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

Last updated