Skip to content

RmqRecordOptions

reference
1 min readUpdated

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

PropertyType
expiration`string
userIdstring
CC`string
mandatoryboolean
persistentboolean
deliveryMode`boolean
BCC`string
contentTypestring
contentEncodingstring
headersRecord<string, string>
prioritynumber
messageIdstring
timestampnumber
typestring
appIdstring

Diagram

mermaid
graph 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

ts
import 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; use headers: {} when no custom headers are needed.
  • Use expiration as a millisecond value or RabbitMQ-compatible string, and ensure it matches the intended message TTL behavior.
  • Use CC and BCC for additional broker routing targets; provide either a single queue name or an array of queue names.
  • Prefer deliveryMode: 2 and persistent: true for messages that should survive broker restarts.
  • Keep headers values as strings, serializing complex values before assigning them.

Was this page helpful?

Download as PDF
RmqRecordOptions — NestJS head-to-head