Skip to content

amqpx v1.0.1


amqpx / index / BatchConsumer

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 ParameterDefault type
Message-
AdditionalPropertiesRecord<string, unknown>

Accessors

channel

Get Signature

get channel(): Channel

Defined in: src/consumer/batch-consumer.ts:46

The channel used by this consumer.

Returns

Channel


queue

Get Signature

get queue(): Queue

Defined in: src/consumer/batch-consumer.ts:41

The queue this consumer reads from.

Returns

Queue

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

ParameterTypeDescription
timeout?numberMaximum 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

ParameterTypeDescription
callbackBatchConsumerCallbackFn<Message, AdditionalProperties>Handler invoked with a batch of received messages.

Returns

Promise<BatchConsumer<Message, AdditionalProperties>>

Released under the MIT License.