Message attributes
Attributes are metadata sent alongside a message. This page explains where they travel and what kinds there are.
When a transport such as RabbitMQ or Amazon SQS sends a message, it wraps it in an envelope. Commands and events are serialized into the body, and attributes go in its headers. Use attributes for technical concerns, such as routing the message, or for auditing and logging, such as who or what sent it.
Handlers receive the attributes as their second argument, a MessageAttributes with three parts:
Correlation idAn id that relates messages to each other. It's copied to every message sent while handling one that has it.AttributesValues for the receiver of this message only.Sticky attributesValues copied to every message sent while handling this one, and the ones after it.
attributes and stickyAttributes are always objects in a handler, even when the sender didn't set any, so read them without ?.. Values can be strings, numbers or booleans.
See also
- Messages
MessageAttributesin the API reference