Skip to content

amqpx v1.0.1


amqpx / index / ConsumerImplementation

Class: ConsumerImplementation<Message> ​

Defined in: src/consumer/consumer-implementation.ts:18

Represents a service consuming messages from RabbitMQ. The generic type Message is the type of the parsed message payload, and AdditionalProperties are extra fields that a consumer implementation can add to the callback arguments.

Extends ​

Type Parameters ​

Type Parameter
Message

Implements ​

Constructors ​

Constructor ​

new ConsumerImplementation<Message>(channel, queue, options): ConsumerImplementation<Message>

Defined in: src/consumer/consumer-implementation.ts:23

Parameters ​

ParameterType
channelChannel
queueQueue
optionsConsumerOptions<Message>

Returns ​

ConsumerImplementation<Message>

Overrides ​

BaseConsumer<ConsumerCallbackFn<Message>, ConsumerEventMap>.constructor

Properties ​

PropertyModifierTypeDefault valueInherited fromDefined in
channelreadonlyChannelundefinedConsumer.channel BaseConsumer.channelsrc/consumer/base-consumer.ts:39
consumerprotectedPromise<ConsumerWrapper<ConsumerCallbackFn<Message>>> | nullnullBaseConsumer.consumersrc/consumer/base-consumer.ts:34
notifyMessageProcessedprotected(() => void) | undefinedundefinedBaseConsumer.notifyMessageProcessedsrc/consumer/base-consumer.ts:35
queuereadonlyQueueundefinedConsumer.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 message handlers to finish.

Parameters ​

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

Returns ​

Promise<void>

Implementation of ​

Consumer.close

Inherited from ​

BaseConsumer.close


listen() ​

listen(callback): Promise<ConsumerImplementation<Message>>

Defined in: src/consumer/consumer-implementation.ts:32

Registers the message handler and starts consuming from the queue.

Parameters ​

ParameterTypeDescription
callbackConsumerCallbackFn<Message>Handler invoked for each received message.

Returns ​

Promise<ConsumerImplementation<Message>>

Implementation of ​

Consumer.listen

Overrides ​

BaseConsumer.listen

Released under the MIT License.