Kind: Class
Source: packages/microservices/record-builders/rmq.record-builder.ts
Part of: Microservices
RmqRecordBuilder constructs RmqRecord instances for RabbitMQ-based microservice messages. It provides a fluent API for attaching message data and RabbitMQ publishing options before producing the final record with build().
Methods
| Method | Signature | Returns |
|---|---|---|
setOptions | setOptions(options: RmqRecordOptions) | this |
setData | setData(data: TData) | this |
build | build() | RmqRecord |
Diagram
mermaidgraph LR A[Application message data] --> B[RmqRecordBuilder] C[RabbitMQ publish options] --> B B -->|setData() / setOptions()| D[Configured builder] D -->|build()| E[RmqRecord] E --> F[RMQ client transport]
Usage
tsimport { RmqRecordBuilder } from '@nestjs/microservices';
const record = new RmqRecordBuilder()
.setData({
event: 'order.created',
orderId: 'order-123',
})
.setOptions({
persistent: true,
headers: {
'x-correlation-id': 'request-456',
},
})
.build();
// Example: publish through an injected NestJS ClientProxy
client.emit('orders.events', record);
AI Coding Instructions
- Use the fluent chain
setData(...).setOptions(...).build()when creating RabbitMQ records. - Call
build()only after providing the payload required by the receiving consumer. - Keep transport-specific settings, such as
persistentand message headers, insetOptions()rather than mixing them into the data payload. - Pass the built
RmqRecordto RMQ-enabledClientProxymethods such asemit()orsend().
Used by
1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Imported by (1)
RMQController—integration/microservices/src/rmq/rmq.controller.ts:16
Was this page helpful?