Skip to content

amqpx v1.0.1


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

Type Parameters

Type Parameter
Message

Implements

Constructors

Constructor

new BatchConsumerImplementation<Message>(channel, queue, options?): BatchConsumerImplementation<Message>

Defined in: src/consumer/batch-consumer-implementation.ts:29

Parameters

ParameterType
channelChannel
queueQueue
optionsBatchConsumerOptions<Message>

Returns

BatchConsumerImplementation<Message>

Overrides

BaseConsumer<BatchConsumerCallbackFn<Message>, BatchConsumerEventMap>.constructor

Properties

PropertyModifierTypeDefault valueInherited fromDefined in
channelreadonlyChannelundefinedBatchConsumer.channel BaseConsumer.channelsrc/consumer/base-consumer.ts:39
consumerprotectedPromise<ConsumerWrapper<BatchConsumerCallbackFn<Message>>> | nullnullBaseConsumer.consumersrc/consumer/base-consumer.ts:34
notifyMessageProcessedprotected(() => void) | undefinedundefinedBaseConsumer.notifyMessageProcessedsrc/consumer/base-consumer.ts:35
queuereadonlyQueueundefinedBatchConsumer.queue BaseConsumer.queuesrc/consumer/base-consumer.ts:40

Methods

channelCloseCallback()

protected readonly channelCloseCallback(): 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

ParameterTypeDefault valueDescription
timeoutnumber30000Maximum time in milliseconds to wait for in-flight messages to complete. Defaults to 30000.

Returns

Promise<void>

Implementation of

BatchConsumer.close

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

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

Returns

Promise<BatchConsumerImplementation<Message>>

Implementation of

BatchConsumer.listen

Overrides

BaseConsumer.listen

Released under the MIT License.