Skip to content

API reference / @node-ts/bus-messages / messageAttributes

Function: messageAttributes() ​

ts
function messageAttributes<AttributesType, StickyAttributesType>(...input): MessageAttributes<AttributesType, StickyAttributesType>;

Defined in: packages/bus-messages/src/message-attributes.ts:75

Creates MessageAttributes with attributes and stickyAttributes defaulted to {}, so a test can call a handler directly without spelling out empty attributes. Handlers still receive both fields, so they read them without ?..

Type Parameters ​

Type ParameterDefault type
AttributesType extends MessageAttributeMapobject
StickyAttributesType extends MessageAttributeMapobject

Parameters ​

ParameterTypeDescription
...inputobject extends AttributesType & StickyAttributesType ? [MessageAttributesInput<AttributesType, StickyAttributesType>] : [MessageAttributesInput<AttributesType, StickyAttributesType>]the correlation id and the attributes to set

Returns ​

MessageAttributes<AttributesType, StickyAttributesType>

message attributes with any missing attributes or stickyAttributes set to {}

Examples ​

ts
await placeOrderHandler.messageHandler(PlaceOrder({ orderId: '1' }), messageAttributes(), fakeContext)
ts
messageAttributes({ correlationId: 'c', attributes: { tenantId: 'a' } })

Released under the MIT License.