Class: Consumer
TypeScript 0.4.0 · Source commit cbff27b8a34e1384384018680e46c20d5c610cc9. Generated with reviewed comment corrections; see generation notes.
Defined in: consumer.ts:75
Consumer class for consuming messages from a queue.
- Implements an asynchronous iterator pattern for message consumption
via
messages(). - Supports automatic visibility timeout extension (autoExtension) that renews in-flight messages to reduce redelivery during processing. Renewal can fail or arrive too late; handlers must tolerate duplicate delivery.
Methods
getQueueName()
getQueueName():
string
Defined in: consumer.ts:496
Returns
string
messages()
messages():
AsyncIterableIterator<Message>
Defined in: consumer.ts:546
Start claiming messages and return their asynchronous iterator.
An uncached queue requires an explicit topic option: there is no database
lookup fallback, and a missing topic throws here before claiming starts.
Breaking out of a for await loop calls the iterator's return method, which
awaits stop(). Settle the current delivery before exiting to avoid waiting
for the shutdown timeout.
Returns
AsyncIterableIterator<Message>
Asynchronous iterator that yields messages.
onClose()
onClose(
listener):void
Defined in: consumer.ts:518
onClose registers a listener for when this consumer closes. It fires once with a QueueFatalError if the consumer was torn down because its queue is gone, or with no argument on a normal stop(). If the consumer has already closed, the listener fires on the next microtask. Mirrors the RabbitMQ Go client's Channel.NotifyClose.
Parameters
listener
(err?) => void
Returns
void
stop()
stop():
Promise<void>
Defined in: consumer.ts:456
Stop new claims, abort in-flight message signals, and release buffered
messages that have not been handed to application code. Wait for fetches,
releases, and handed-out deliveries to settle within shutdownTimeoutMs,
or the remaining connection-close budget. After the deadline, tracking and
renewal end; unfinished deliveries can be reclaimed after their visibility
timeouts. An abort signal asks work to stop; it does not settle a delivery.
Repeated calls share the same shutdown promise.
Returns
Promise<void>
Promise that resolves when shutdown finishes or its budget expires.