Interface: BatchConsumer<Message, AdditionalProperties>
Defined in: src/consumer/batch-consumer.ts:22
Represents a service consuming messages from RabbitMQ in batches. The generic type Message is the type of each parsed message payload, and AdditionalProperties are extra fields that a consumer implementation can add to each message entry in the callback.
Extends
EventEmitter<BatchConsumerEventMap>
Type Parameters
| Type Parameter | Default type |
|---|---|
Message | - |
AdditionalProperties | Record<string, unknown> |
Accessors
channel
Get Signature
get channel():
Channel
Defined in: src/consumer/batch-consumer.ts:46
The channel used by this consumer.
Returns
queue
Get Signature
get queue():
Queue
Defined in: src/consumer/batch-consumer.ts:41
The queue this consumer reads from.
Returns
Methods
close()
close(
timeout?):Promise<void>
Defined in: src/consumer/batch-consumer.ts:30
Stops consuming new messages and waits for all in-flight batches to finish processing.
Parameters
| Parameter | Type | Description |
|---|---|---|
timeout? | number | Maximum time in milliseconds to wait for in-flight messages to complete. Defaults to 30000. |
Returns
Promise<void>
listen()
listen(
callback):Promise<BatchConsumer<Message,AdditionalProperties>>
Defined in: src/consumer/batch-consumer.ts:36
Registers the batch handler and starts consuming from the queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | BatchConsumerCallbackFn<Message, AdditionalProperties> | Handler invoked with a batch of received messages. |
Returns
Promise<BatchConsumer<Message, AdditionalProperties>>