📘
@node-test/bus
  • @node-ts/bus
  • Getting started
    • Installation
    • Handling messages
    • Shutting down cleanly
  • Reference
    • Bus
    • BusConfiguration
    • BusInstance
  • Getting help
  • Guide
    • Messages
      • Events
      • Commands
      • System messages
    • Message attributes
      • Correlation id
      • Attributes
      • Sticky attributes
    • Workflows
      • Creating a workflow
      • Starting
      • Handling
      • State
      • Completing
      • Example
    • Transports
      • RabbitMQ
      • Amazon SQS
      • Redis
      • Custom transports
    • Persistence
      • Postgres
      • MongoDB
      • Creating a persistence
    • Serializers
      • Class serializer
    • Loggers
      • Custom loggers
    • Middleware
    • Lifecycle hooks
    • Retry Strategies
    • Dependency injection
    • Long running processes
Powered by GitBook
On this page

Was this helpful?

  1. Guide
  2. Message attributes

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()
PreviousAttributesNextWorkflows

Last updated 3 years ago

Was this helpful?