amqpx / index / BatchConsumerImplementation
Class: BatchConsumerImplementation<Message>
Defined in: src/consumer/batch-consumer-implementation.ts:21
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
BaseConsumer<BatchConsumerCallbackFn<Message>,BatchConsumerEventMap>
Type Parameters
| Type Parameter |
|---|
Message |
Implements
BatchConsumer<Message>
Constructors
Constructor
new BatchConsumerImplementation<
Message>(channel,queue,options?):BatchConsumerImplementation<Message>
Defined in: src/consumer/batch-consumer-implementation.ts:29
Parameters
| Parameter | Type |
|---|---|
channel | Channel |
queue | Queue |
options | BatchConsumerOptions<Message> |
Returns
BatchConsumerImplementation<Message>
Overrides
BaseConsumer<BatchConsumerCallbackFn<Message>, BatchConsumerEventMap>.constructor
Properties
| Property | Modifier | Type | Default value | Inherited from | Defined in |
|---|---|---|---|---|---|
channel | readonly | Channel | undefined | BatchConsumer.channel BaseConsumer.channel | src/consumer/base-consumer.ts:39 |
consumer | protected | Promise<ConsumerWrapper<BatchConsumerCallbackFn<Message>>> | null | null | BaseConsumer.consumer | src/consumer/base-consumer.ts:34 |
notifyMessageProcessed | protected | (() => void) | undefined | undefined | BaseConsumer.notifyMessageProcessed | src/consumer/base-consumer.ts:35 |
queue | readonly | Queue | undefined | BatchConsumer.queue BaseConsumer.queue | src/consumer/base-consumer.ts:40 |
Methods
channelCloseCallback()
protectedreadonlychannelCloseCallback():void
Defined in: src/consumer/base-consumer.ts:45
Returns
void
Inherited from
BaseConsumer.channelCloseCallback
close()
close(
timeout?):Promise<void>
Defined in: src/consumer/base-consumer.ts:67
Stops consuming new messages and waits for all in-flight batches to finish processing.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
timeout | number | 30000 | Maximum time in milliseconds to wait for in-flight messages to complete. Defaults to 30000. |
Returns
Promise<void>
Implementation of
Inherited from
BaseConsumer.close
listen()
listen(
callback):Promise<BatchConsumerImplementation<Message>>
Defined in: src/consumer/batch-consumer-implementation.ts:40
Registers the batch handler and starts consuming from the queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | BatchConsumerCallbackFn<Message> | Handler invoked with a batch of received messages. |
Returns
Promise<BatchConsumerImplementation<Message>>
Implementation of
Overrides
BaseConsumer.listen