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

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

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.

**Signature:**

```typescript
publish(data: JsonObject, toName?: string): Promise<void>;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| data | [JsonObject](https://imqueue.org/api/core/latest/core.jsonobject/) | payload to publish as a channel message |
| toName | string | _(Optional)_ optional different pub/sub name to publish to; must be a bare name inside the same prefix namespace, not a full Redis channel key |


**Returns:**

Promise<void>

## Exceptions

TypeError when the queue has no writer connection

## Remarks

Unlike [RedisQueue.send()](https://imqueue.org/api/core/latest/core.redisqueue.send/), this does not start the queue implicitly, so [RedisQueue.start()](https://imqueue.org/api/core/latest/core.redisqueue.start/) must have completed first. It is allowed in any [IMQMode](https://imqueue.org/api/core/latest/core.imqmode/), including `WORKER`.

The payload is always plain JSON — [IMQOptions.useGzip](https://imqueue.org/api/core/latest/core.imqoptions.usegzip/) applies to queue messages only. Redis pub/sub drops the message silently when nobody is subscribed.

