Home > @imqueue/rpc > RedisQueue

RedisQueue class

Class RedisQueue Implements a simple messaging queue over redis.

Signature:

export declare class RedisQueue extends EventEmitter<EventMap> implements IMessageQueue 

Extends: EventEmitter<EventMap>

Implements: IMessageQueue

Constructors

Constructor

Modifiers

Description

(constructor)(name, options, mode)

Constructs a new instance of the RedisQueue class

Properties

Property

Modifiers

Type

Description

available

readonly

boolean

Returns false only when this queue is known to be unable to accept writes right now — i.e., it has a writer connection currently in a non-ready (reconnecting/closed) state. A queue that has not yet connected is considered available, since a sending lazily connects it. Used for health-aware routing in the clustered queue.

name

string

options

IMQOptions

This queue instance options

{IMQOptions}

redisKey

readonly

string

This queue instance unique key (identifier), for internal use

Methods

Method

Modifiers

Description

clear()

Clears queue data in redis

destroy(clearData)

Gracefully destroys this queue handle. Does not remove queue data from redis unless clearData is explicitly set to true, so that destroying one handle (e.g., on scale-down) never wipes messages still pending for other producers/consumers.

isPublisher()

Returns true if publisher mode is enabled on this queue, false otherwise.

isWorker()

Returns true if worker mode is enabled on this queue, false otherwise.

publish(data, toName)

Publishes a message to this queue subscription channel for currently subscribed clients.

If toName specified will publish to PubSub with a different name. This can be used to implement broadcasting some messages to other subscribers on other PubSub channels.

queueLength()

Retrieves the current count of messages in the queue

send(toQueue, message, delay, errorHandler)

Sends a given message to a given queue (by name)

start()

Initializes and starts current queue routines

stop()

Stops current queue routines

subscribe(channel, handler)

Creates a subscription channel over redis and sets up channel data read handler

unsubscribe()

Closes subscription channel