Skip to content

amqpx v1.0.1


amqpx / index / Consumer

Interface: Consumer<Message, AdditionalProperties> ​

Defined in: src/consumer/consumer.ts:24

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 ​

  • EventEmitter<ConsumerEventMap>

Type Parameters ​

Type ParameterDefault type
Message-
AdditionalPropertiesRecord<string, unknown>

Accessors ​

channel ​

Get Signature ​

get channel(): Channel

Defined in: src/consumer/consumer.ts:45

The channel used by this consumer.

Returns ​

Channel


queue ​

Get Signature ​

get queue(): Queue

Defined in: src/consumer/consumer.ts:40

The queue this consumer reads from.

Returns ​

Queue

Methods ​

close() ​

close(timeout?): Promise<void>

Defined in: src/consumer/consumer.ts:29

Stops consuming new messages and waits for all in-flight message handlers to finish.

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<Consumer<Message, AdditionalProperties>>

Defined in: src/consumer/consumer.ts:35

Registers the message handler and starts consuming from the queue.

Parameters ​

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

Returns ​

Promise<Consumer<Message, AdditionalProperties>>

Released under the MIT License.