# IMQClient class · @imqueue/rpc

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

Base class for service clients.

Subclass it and declare every remote method as `@remote() async m(...args) \{ return await this.remoteCall<T>(...arguments); \}`, or let [IMQClient.create()](https://imqueue.org/api/rpc/latest/rpc.imqclient.create/) generate the subclass from a running service's description.

**Signature:**

```typescript
export declare abstract class IMQClient extends EventEmitter 
```
**Extends:** EventEmitter

## Remarks

Abstractness is enforced at runtime as well as by the type system: constructing `IMQClient` directly throws a `TypeError`.

Instances are `EventEmitter`s. Besides ordinary calls, any response that no longer has a pending caller is emitted as an event named after the remote method, carrying the raw [IMQRPCResponse](https://imqueue.org/api/rpc/latest/rpc.imqrpcresponse/) — the escape hatch for replies to calls made by a process that has since died.

The identity properties pair up as follows: [IMQClient.serviceName](https://imqueue.org/api/rpc/latest/rpc.imqclient.servicename/) is where calls go, [IMQClient.queueName](https://imqueue.org/api/rpc/latest/rpc.imqclient.queuename/) is where answers come back, [IMQClient.name](https://imqueue.org/api/rpc/latest/rpc.imqclient.name/) identifies this client, [IMQClient.hostName](https://imqueue.org/api/rpc/latest/rpc.imqclient.hostname/) identifies the machine plus instance, and [IMQClient.id](https://imqueue.org/api/rpc/latest/rpc.imqclient.id/) is the per-host instance slot.

## Constructors


| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(options, serviceName, name)](https://imqueue.org/api/rpc/latest/rpc.imqclient._constructor_/) |  | Constructs a client. |


## Properties


| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [hostName](https://imqueue.org/api/rpc/latest/rpc.imqclient.hostname/) | `readonly` | string | Machine-scoped identity, `"<osUuid>-<id>:client"`, where `osUuid` is a hash of the OS machine id. |
| [id](https://imqueue.org/api/rpc/latest/rpc.imqclient.id/) | `readonly` | number | Per-host instance slot number — not an OS process id. |
| [name](https://imqueue.org/api/rpc/latest/rpc.imqclient.name/) | `readonly` | string | This client's unique identity, `"<baseName>-<hostName>"`. |
| [options](https://imqueue.org/api/rpc/latest/rpc.imqclient.options/) | `readonly` | [IMQClientOptions](https://imqueue.org/api/rpc/latest/rpc.imqclientoptions/) | The effective options for this client: [DEFAULT\_IMQ\_CLIENT\_OPTIONS](https://imqueue.org/api/rpc/latest/rpc.default_imq_client_options/) merged with the values passed to the constructor. |
| [queueName](https://imqueue.org/api/rpc/latest/rpc.imqclient.queuename/) | `readonly` | string | The local side: the queue replies come back on, and the value placed in `request.from`. |
| [serviceName](https://imqueue.org/api/rpc/latest/rpc.imqclient.servicename/) | `readonly` | string | The remote side: the queue every request is addressed to, and the pub/sub channel [IMQClient.subscribe()](https://imqueue.org/api/rpc/latest/rpc.imqclient.subscribe/) listens on. |


## Methods


| Method | Modifiers | Description |
| --- | --- | --- |
| [broadcast(payload)](https://imqueue.org/api/rpc/latest/rpc.imqclient.broadcast/) |  | Publishes the given payload on this client's own queue channel ([IMQClient.queueName](https://imqueue.org/api/rpc/latest/rpc.imqclient.queuename/)). |
| [create(name, options)](https://imqueue.org/api/rpc/latest/rpc.imqclient.create/) | `static` | Generates a client for the service registered under the given queue name and resolves to the generated namespace object — not to a client instance, and not to an [IMQClient](https://imqueue.org/api/rpc/latest/rpc.imqclient/). |
| [describe(\_delay)](https://imqueue.org/api/rpc/latest/rpc.imqclient.describe/) |  | Returns service description metadata. |
| [destroy()](https://imqueue.org/api/rpc/latest/rpc.imqclient.destroy/) |  | Destroys client |
| [remoteCall(args)](https://imqueue.org/api/rpc/latest/rpc.imqclient.remotecall/) | `protected` | Sends a call to the remote service method. Intended to be invoked as `this.remoteCall<T>(...arguments)` from a method decorated with [remote()](https://imqueue.org/api/rpc/latest/rpc.remote/), which appends the method name for you. |
| [start()](https://imqueue.org/api/rpc/latest/rpc.imqclient.start/) |  | Initializes client work |
| [stop()](https://imqueue.org/api/rpc/latest/rpc.imqclient.stop/) |  | Stops client work |
| [subscribe(handler)](https://imqueue.org/api/rpc/latest/rpc.imqclient.subscribe/) |  | Subscribes to the service's event channel, named after [IMQClient.serviceName](https://imqueue.org/api/rpc/latest/rpc.imqclient.servicename/) — the same channel a service's `publish()` writes to, so every client of that service receives every published payload. |
| [unsubscribe()](https://imqueue.org/api/rpc/latest/rpc.imqclient.unsubscribe/) |  | Stops receiving service events: unsubscribes the channel, discards every handler registered through [IMQClient.subscribe()](https://imqueue.org/api/rpc/latest/rpc.imqclient.subscribe/), and closes the dedicated subscription connection. |

