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
BaseConsumer<ConsumerCallbackFn<Message>,ConsumerEventMap>
Type Parameters
| Type Parameter |
|---|
Message |
Implements
Consumer<Message>
Constructors
Constructor
new ConsumerImplementation<
Message>(channel,queue,options):ConsumerImplementation<Message>
Defined in: src/consumer/consumer-implementation.ts:23
Parameters
| Parameter | Type |
|---|---|
channel | Channel |
queue | Queue |
options | ConsumerOptions<Message> |
Returns
ConsumerImplementation<Message>
Overrides
BaseConsumer<ConsumerCallbackFn<Message>, ConsumerEventMap>.constructor
Properties
| Property | Modifier | Type | Default value | Inherited from | Defined in |
|---|---|---|---|---|---|
channel | readonly | Channel | undefined | Consumer.channel BaseConsumer.channel | src/consumer/base-consumer.ts:39 |
consumer | protected | Promise<ConsumerWrapper<ConsumerCallbackFn<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 | Consumer.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 message handlers to finish.
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<ConsumerImplementation<Message>>
Defined in: src/consumer/consumer-implementation.ts:32
Registers the message handler and starts consuming from the queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | ConsumerCallbackFn<Message> | Handler invoked for each received message. |
Returns
Promise<ConsumerImplementation<Message>>
Implementation of
Overrides
BaseConsumer.listen