Kind: Interface
Source: packages/microservices/record-builders/rmq.record-builder.ts
Part of: Microservices
RmqRecordOptions defines RabbitMQ message properties used when building a record for publishing through the microservices layer. It controls message lifetime, routing metadata, delivery behavior, content metadata, and custom headers passed to the RabbitMQ broker.
Properties
| Property | Type |
|---|---|
expiration | `string |
userId | string |
CC | `string |
mandatory | boolean |
persistent | boolean |
deliveryMode | `boolean |
BCC | `string |
contentType | string |
contentEncoding | string |
headers | Record<string, string> |
priority | number |
messageId | string |
timestamp | number |
type | string |
appId | string |
Diagram
mermaidgraph LR A[Application Message] --> B[RmqRecordOptions] B --> C[RMQ Record Builder] C --> D[RabbitMQ Publish Properties] B --> E[Routing: CC / BCC] B --> F[Delivery: mandatory / persistent / deliveryMode] B --> G[Metadata: contentType / contentEncoding / headers] B --> H[Lifetime: expiration]
Usage
tsimport type { RmqRecordOptions } from './rmq.record-builder';
const options: RmqRecordOptions = {
expiration: 60_000,
userId: 'notification-service',
CC: ['audit.queue'],
BCC: 'internal-monitoring.queue',
mandatory: true,
persistent: true,
deliveryMode: 2,
contentType: 'application/json',
contentEncoding: 'utf-8',
headers: {
'x-request-id': 'req_123456',
'x-message-source': 'notifications',
},
};
// Pass options to the RMQ record/message builder used by your publisher.
AI Coding Instructions
- Provide all required properties when creating
RmqRecordOptions; useheaders: {}when no custom headers are needed. - Use
expirationas a millisecond value or RabbitMQ-compatible string, and ensure it matches the intended message TTL behavior. - Use
CCandBCCfor additional broker routing targets; provide either a single queue name or an array of queue names. - Prefer
deliveryMode: 2andpersistent: truefor messages that should survive broker restarts. - Keep
headersvalues as strings, serializing complex values before assigning them.
Was this page helpful?