Access the AMQP channel via RmqContext.getChannelRef() and the raw message via ctx.getMessage(). Call channel.ack() on success and channel.nack() on failure. The second and third arguments to nack() control whether the message is requeued or dead-lettered.
noAck: false must be set in the microservice options — otherwise NestJS auto-acks before your handler runs.
channel.ack(msg) — removes the message from the queue after successful processing.
channel.nack(msg, false, true) — returns the message to the queue for redelivery.
channel.nack(msg, false, false) — dead-letters the message instead of requeuing.
Always ack or nack in a try/finally to prevent message leaks if the handler throws unexpectedly.
You need to consume messages from a RabbitMQ queue in a NestJS microservice and ensure each message is only removed after processing succeeds. How would you set up the listener to manually acknowledge messages?
If your handler throws an exception after you've already called channel.ack, what will happen to the message in the queue, and how would you prevent that?
During a recent feature you added, messages started being requeued repeatedly causing a processing loop. Walk me through how you'd debug the manual ack implementation in NestJS.
Explain the trade‑offs between using channel.ack versus channel.nack with the requeue flag when handling high‑volume order events.
Design a robust message consumption layer in NestJS that uses manual acknowledgements, handles back‑pressure, and guarantees at‑least‑once delivery across multiple instances. What components would you introduce and why?
How would you modify your manual ack strategy to support graceful shutdown of a NestJS service without losing in‑flight messages?
Your organization is migrating from auto‑ack to manual ack across dozens of NestJS services. What architectural changes, testing strategies, and cross‑team coordination would you plan to ensure reliability?
Consider a scenario where a downstream system is slow, causing message processing latency. How would you redesign the RabbitMQ‑NestJS integration, including manual ack handling, to maintain throughput while preventing message pile‑up?