UNPKG

@cloudamqp/amqp-client

Version:

AMQP 0-9-1 client, both for browsers (WebSocket) and node (TCP Socket)

43 lines 1.75 kB
import type { AMQPMessage } from "./amqp-message.js"; import type { AMQPProperties } from "./amqp-properties.js"; import type { ResolveBody } from "./amqp-publisher.js"; import type { ParserMap, CoderMap } from "./amqp-codec-registry.js"; /** * Reusable RPC client using the direct reply-to feature. * * @example * ```ts * const session = await AMQPSession.connect("amqp://localhost") * const rpc = await session.rpcClient() // tracked for reconnect recovery * const reply = await rpc.call("my_queue", "request body") * console.log(reply.bodyString()) * await rpc.close() * ``` */ export declare class AMQPRPCClient<P extends ParserMap = {}, C extends CoderMap = {}, KP extends keyof P & string = never, KC extends keyof C & string = never> { private readonly session; private ch; private correlationId; private readonly pending; private closed; /** * Perform an RPC call: publish a message and wait for the response. * * @param queue - The queue name (routing key) of the RPC server * @param body - The request body * @param options - Optional properties and timeout * @param options.timeout - Timeout in milliseconds. Rejects with an error if * no response is received within this time. * @returns The reply {@link AMQPMessage} */ call(queue: string, body: ResolveBody<P, KP>, { timeout, ...properties }?: AMQPProperties & { timeout?: number; }): Promise<AMQPMessage<P>>; /** * Close the dedicated channel, reject any pending calls, and remove * this client from the session's reconnect recovery. */ close(): Promise<void>; private rejectAllPending; } //# sourceMappingURL=amqp-rpc-client.d.ts.map