Skip to content

Latest commit

 

History

History
369 lines (211 loc) · 6.01 KB

Consumer.md

File metadata and controls

369 lines (211 loc) · 6.01 KB

RedisSMQ / Docs / API Reference / Consumer

Class: Consumer

Hierarchy

Table of contents

Constructors

Methods

Constructors

constructor

new Consumer(enableMultiplexing?): Consumer

Parameters

Name Type
enableMultiplexing? boolean

Returns

Consumer

Overrides

Runnable<TConsumerEvent>.constructor

Methods

cancel

cancel(queue, cb): void

Cancel consuming messages from the provided queue.

Parameters

Name Type Description
queue TQueueExtendedParams Queue parameters
cb ICallback<void> A callback function

Returns

void


consume

consume(queue, messageHandler, cb): void

Start listening for messages on the specified queue.

Parameters

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.

Returns

void

See

https://github.com/weyoss/redis-smq/blob/master/docs/consuming-messages.md


emit

emit<E>(event, ...args): boolean

Type parameters

Name Type
E extends keyof TConsumerEvent

Parameters

Name Type
event E
...args Parameters<TConsumerEvent[E]>

Returns

boolean

Inherited from

Runnable.emit


getId

getId(): string

Returns

string

Inherited from

Runnable.getId


getQueues

getQueues(): IQueueParsedParams[]

Retrieve the list of queues being consumed by a Consumer instance.

Returns

IQueueParsedParams[]

  • Queue list

isDown

isDown(): boolean

Returns

boolean

Inherited from

Runnable.isDown


isGoingDown

isGoingDown(): boolean

Returns

boolean

Inherited from

Runnable.isGoingDown


isGoingUp

isGoingUp(): boolean

Returns

boolean

Inherited from

Runnable.isGoingUp


isRunning

isRunning(): boolean

Returns

boolean

Inherited from

Runnable.isRunning


isUp

isUp(): boolean

Returns

boolean

Inherited from

Runnable.isUp


on

on<E>(event, listener): this

Type parameters

Name Type
E extends keyof TConsumerEvent

Parameters

Name Type
event E
listener TConsumerEvent[E]

Returns

this

Inherited from

Runnable.on


once

once<E>(event, listener): this

Type parameters

Name Type
E extends keyof TConsumerEvent

Parameters

Name Type
event E
listener TConsumerEvent[E]

Returns

this

Inherited from

Runnable.once


removeAllListeners

removeAllListeners<E>(event?): this

Type parameters

Name Type
E extends keyof TConsumerEvent

Parameters

Name Type
event? Extract<E, string>

Returns

this

Inherited from

Runnable.removeAllListeners


removeListener

removeListener<E>(event, listener): this

Type parameters

Name Type
E extends keyof TConsumerEvent

Parameters

Name Type
event E
listener TConsumerEvent[E]

Returns

this

Inherited from

Runnable.removeListener


run

run(cb): void

Parameters

Name Type
cb ICallback<boolean>

Returns

void

Inherited from

Runnable.run


shutdown

shutdown(cb): void

Parameters

Name Type
cb ICallback<void>

Returns

void

Inherited from

Runnable.shutdown