RedisSMQ / Docs / API Reference / Consumer
-
Runnable
<TConsumerEvent
>↳
Consumer
- cancel
- consume
- emit
- getId
- getQueues
- isDown
- isGoingDown
- isGoingUp
- isRunning
- isUp
- on
- once
- removeAllListeners
- removeListener
- run
- shutdown
• new Consumer(enableMultiplexing?
): Consumer
Name | Type |
---|---|
enableMultiplexing? |
boolean |
Runnable<TConsumerEvent>.constructor
▸ cancel(queue
, cb
): void
Cancel consuming messages from the provided queue.
Name | Type | Description |
---|---|---|
queue |
TQueueExtendedParams |
Queue parameters |
cb |
ICallback <void > |
A callback function |
void
▸ consume(queue
, messageHandler
, cb
): void
Start listening for messages on the specified queue.
Name | Type | Description |
---|---|---|
queue |
TQueueExtendedParams |
A queue from which messages will be consumed. Before consuming messages from a queue make sure that the specified queue already exists in the system. |
messageHandler |
TConsumerMessageHandler |
A callback function that defines how to process each message consumed from the queue. The messageHandler will receive the message as an argument and should implement the logic for processing the message. This might include business logic, transformation, storage, etc. It's crucial that this function handles exceptions and errors properly to avoid issues with message acknowledgment. |
cb |
ICallback <void > |
The callback function will be executed after the consumption process is initiated. It typically signifies the end of the consumption setup and can be used to handle success or errors in starting the consumption process. |
void
See
https://github.com/weyoss/redis-smq/blob/master/docs/consuming-messages.md
▸ emit<E
>(event
, ...args
): boolean
Name | Type |
---|---|
E |
extends keyof TConsumerEvent |
Name | Type |
---|---|
event |
E |
...args |
Parameters <TConsumerEvent [E ]> |
boolean
Runnable.emit
▸ getId(): string
string
Runnable.getId
▸ getQueues(): IQueueParsedParams
[]
Retrieve the list of queues being consumed by a Consumer instance.
- Queue list
▸ isDown(): boolean
boolean
Runnable.isDown
▸ isGoingDown(): boolean
boolean
Runnable.isGoingDown
▸ isGoingUp(): boolean
boolean
Runnable.isGoingUp
▸ isRunning(): boolean
boolean
Runnable.isRunning
▸ isUp(): boolean
boolean
Runnable.isUp
▸ on<E
>(event
, listener
): this
Name | Type |
---|---|
E |
extends keyof TConsumerEvent |
Name | Type |
---|---|
event |
E |
listener |
TConsumerEvent [E ] |
this
Runnable.on
▸ once<E
>(event
, listener
): this
Name | Type |
---|---|
E |
extends keyof TConsumerEvent |
Name | Type |
---|---|
event |
E |
listener |
TConsumerEvent [E ] |
this
Runnable.once
▸ removeAllListeners<E
>(event?
): this
Name | Type |
---|---|
E |
extends keyof TConsumerEvent |
Name | Type |
---|---|
event? |
Extract <E , string > |
this
Runnable.removeAllListeners
▸ removeListener<E
>(event
, listener
): this
Name | Type |
---|---|
E |
extends keyof TConsumerEvent |
Name | Type |
---|---|
event |
E |
listener |
TConsumerEvent [E ] |
this
Runnable.removeListener
▸ run(cb
): void
Name | Type |
---|---|
cb |
ICallback <boolean > |
void
Runnable.run
▸ shutdown(cb
): void
Name | Type |
---|---|
cb |
ICallback <void > |
void
Runnable.shutdown