UNPKG

@cloudamqp/amqp-client

Version:

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

56 lines 2.17 kB
import type { AMQPChannel } from "./amqp-channel.js"; import type { AMQPMessage } from "./amqp-message.js"; /** * A consumer, subscribed to a queue */ export declare class AMQPConsumer { /** Channel this consumer is attached to. */ readonly channel: AMQPChannel; /** Server-assigned consumer tag. */ readonly tag: string; /** Callback invoked for each delivered message. */ readonly onMessage: (msg: AMQPMessage) => void | Promise<void>; protected closed: boolean; protected closedError?: Error; private resolveWait?; private rejectWait?; private timeoutId?; /** * @param channel - the consumer is created on * @param tag - consumer tag * @param onMessage - callback executed when a message arrive */ constructor(channel: AMQPChannel, tag: string, onMessage: (msg: AMQPMessage) => void | Promise<void>); /** * Wait for the consumer to finish. * @param [timeout] wait for this many milliseconds and then return regardless * @return Fulfilled when the consumer/channel/connection is closed by the client. Rejected if the timeout is hit. */ wait(timeout?: number): Promise<void>; /** * Cancel/abort/stop the consumer. No more messages will be deliviered to the consumer. * Note that any unacked messages are still unacked as they belong to the channel and not the consumer. * Safe to call multiple times — concurrent calls share the same underlying wire operation. */ cancel(): Promise<AMQPChannel>; private cancelPromise?; /** * @ignore * @param [err] - why the consumer was closed */ setClosed(err?: Error): void; } export declare class AMQPGeneratorConsumer extends AMQPConsumer { private messageQueue; private messageResolver; private generator?; constructor(channel: AMQPChannel, tag: string); /** * Get an AsyncGenerator for consuming messages. * @return An AsyncGenerator that yields messages */ get messages(): AsyncGenerator<AMQPMessage, void, undefined>; private generateMessages; setClosed(err?: Error): void; } //# sourceMappingURL=amqp-consumer.d.ts.map