Skip to main content

A queue disappears or a consumer stops

A stopped consumer does not necessarily mean its queue was deleted. Inspect the queue's identity and lifetime, then the consumer's termination error. A Durable queue and an Exclusive queue have different recovery expectations.

Establish the queue's state​

SELECT * FROM postgremq.list_queues() WHERE queue_name = 'jobs';
SELECT * FROM postgremq.queue_metrics() WHERE queue_name = 'jobs';
SELECT * FROM postgremq.list_dlq_messages() WHERE queue_name = 'jobs';

No row means the name is absent in this database. Check database routing, administrative deletion, and maintenance history. A Durable queue is not removed because its final consumer disconnects. If it disappeared, investigate explicit changes or database recovery.

An Exclusive queue can still appear in queue_metrics() with active = 0; list_queues() instead exposes its lifetime fields. Expiry ends use before physical cleanup. Retained dead letters can prevent deletion without making the expired subscription usable.

Check which connection owns lifetime​

The connection that declared an Exclusive queue maintains its lifetime. A different connection receiving from that queue does not take over this responsibility automatically. Stopping a consumer while its declaring connection stays open does not by itself expire the queue.

If the declaring connection closed or could not reach the database, compare the configured lifetime window with the interruption. The window runs from the last successful extension, not from the instant the application notices disconnection. Closing the connection does not promise a fresh full window or immediate deletion.

Look for pool starvation, database errors, long transactions, and queue-loss callbacks. Publishing transactions can delay lifetime extension; keep transactions short and choose a window suited to expected interruptions.

Observe termination​

SDKWhere to observe
GoThe closed message channel, NotifyClose, and configured queue-fatal callback.
RustStream error/end, handler consumer closed(), and configured queue-fatal callback.
TypeScriptIterator end, consumer onClose, and onQueueFatal.

A local shutdown or intentional consumer stop can also end reception. Correlate termination with application lifecycle logs before treating it as a database problem. Check Graceful shutdown for expected cancellation and settlement behavior.

Recover the correct subscription​

For an existing live Durable queue, repair connectivity or application configuration and start a new consumer against that queue. Its retained work remains subject to the normal retry and ordering rules.

An expired Exclusive queue cannot be revived by reconnecting or redeclaring it. Create a new subscription, usually with a new unique name, and accept that it receives only later publications. If missed events are unacceptable, change the application to use a Durable subscription.

Deleting and recreating a queue with the same name produces a new generation. Existing consumers deliberately do not switch to it silently. Start consumers for the replacement after deciding what happened to the old backlog and the publication interval between subscriptions.

Verify recovery by receiving a new test event and observing queue activity. Do not claim historical recovery merely because the replacement can receive new messages.