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
1
await bus.send(
2
new ChargeCreditCard(),
3
{
4
stickyAttributes: {
5
ip: '229.40.202.156',
6
attempt: 0,
7
automatic: true
8
}
9
}
10
)
Copied!
Sticky attributes can be accessed using the stickyAttribtues of the second parameter of a handler.
1
import { MessageAttributes } from '@node-ts/bus-messages'
2
​
3
await Bus.configure()
4
.withHandler(
5
ChargeCreditCard,
6
async (_: ChargeCreditCard, { stickyAttributes }: MessageAttributes) => console.log(attributes)
7
)
8
.initialize()
Copied!
Copy link