# RedisQueue.subscribe() method · @imqueue/core

Source: https://imqueue.org/api/core/latest/core.redisqueue.subscribe/
Published: 2026-08-04
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/core 3.3.2 — generated reference, not hand-written

Creates a subscription channel over redis and sets up channel data read handler. The effective Redis channel is `<prefix>:<channel>`.

**Signature:**

```typescript
subscribe(channel: string, handler: (data: JsonObject) => void): Promise<void>;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| channel | string | channel name within this queue's prefix namespace |
| handler | (data: [JsonObject](https://imqueue.org/api/core/latest/core.jsonobject/)) => void | invoked with the parsed payload of each published message |


**Returns:**

Promise<void>

## Exceptions

TypeError when no channel name is given, or when a different channel name is supplied while a subscription is already open — an instance supports exactly one channel until [RedisQueue.unsubscribe()](https://imqueue.org/api/core/latest/core.redisqueue.unsubscribe/) resets it

## Remarks

Calling this again with the same channel adds another handler rather than replacing the existing one, and every handler is invoked for each message.

A dedicated subscription connection is created on demand, so [RedisQueue.start()](https://imqueue.org/api/core/latest/core.redisqueue.start/) is not required, and the subscription is re-established automatically after a reconnect.

Payloads are parsed as plain JSON ([IMQOptions.useGzip](https://imqueue.org/api/core/latest/core.imqoptions.usegzip/) does not apply to pub/sub). Neither a parse error nor an exception thrown by the handler is contained by the queue, so handlers should not throw.

