IMQClient.create() method
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.
Signature:
static create(name: string, options?: Partial<IMQClientOptions>): Promise<any>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
name |
string |
name of the queue the target service listens on (its service name, which is the class name by default). Also used as the base name of the generated files. |
|
options |
Partial<IMQClientOptions> |
(Optional) client options, merged over DEFAULT_IMQ_CLIENT_OPTIONS |
Returns:
Promise<any>
the generated namespace object, exposing the generated client class (<Service>Client, with a trailing Service replaced by Client) plus one interface per registered service type. It is produced at runtime, so it is typed any — cast it or type the call site yourself. Resolves to null instead when IMQClientOptions.compile is false.
Exceptions
EvalError when the target service does not answer within IMQClientOptions.timeout milliseconds
Remarks
Generating a client requires the target service to be running: this sends a live description request over the queue and fails if no answer arrives in time.
It always transpiles the generated source by spawning TypeScript synchronously, so the call blocks the event loop, and it rejects if transpilation emits nothing. When IMQClientOptions.write is set — the default — it writes both <path>/<name>.ts and <path>/<name>.js, silently overwriting any existing files, and creates path only one level deep.
The identifiers inside the generated module come from the service's own reported class name, so if that differs from name the file name and the namespace/class names differ too.
Example
const ns = await IMQClient.create('UserService');
const client = new ns.UserClient();
await client.start();
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.