Skip to main content

Class: HandlerConsumer

TypeScript 0.4.0 · Source commit cbff27b8a34e1384384018680e46c20d5c610cc9. Generated with reviewed comment corrections; see generation notes.


Defined in: handler-consumer.ts:27

HandlerConsumer wraps a Consumer and dispatches each message to a handler function with optional concurrency limiting (maxInFlight). It is the push-based counterpart to the pull-based for await (const msg of consumer.messages()) iteration, and mirrors the Go client's ConsumeHandler.

Create via Connection.consumeHandler — do not construct directly.

Methods​

getQueueName()​

getQueueName(): string

Defined in: handler-consumer.ts:218

Returns​

string


onClose()​

onClose(listener): void

Defined in: handler-consumer.ts:239

onClose registers a listener for when this consumer closes (with a QueueFatalError if the queue is gone, or no argument on a normal stop) — for a handler consumer this is the primary way to learn the queue is gone, since there is no message iterator to end. Delegates to the underlying consumer.

Parameters​

listener​

(err?) => void

Returns​

void


stop()​

stop(): Promise<void>

Defined in: handler-consumer.ts:176

Stop fetching and abort in-flight handlers' message signals. Wait for the dispatch loop and handlers within ConnectionOptions.shutdownTimeoutMs, or the remaining budget if connection close is already running. The promise can resolve while a handler that ignored cancellation is still running. Apply timeouts to application work and make handlers respond to cancellation; stop cannot forcibly interrupt arbitrary JavaScript. Repeated calls share the same shutdown promise.

Returns​

Promise<void>