Questions
4 of 25
1What is the difference between request-response and event-based (fire-and-forget) message patterns in NestJS microservices?
2What is the @Payload() decorator and how do you use @Ctx() to access transport-specific context in NestJS microservices?
3How do you connect a NestJS microservice to RabbitMQ?
4How do you implement manual message acknowledgement with RabbitMQ in NestJS?
5How do you implement a RabbitMQ topic exchange for routing messages to multiple queues based on routing keys in NestJS?
6How does gRPC differ from REST and when would you choose it for inter-service communication in NestJS?
7How do you implement an API Gateway pattern in NestJS that aggregates multiple microservices?
8How do you implement distributed tracing across NestJS microservices?
9What transport layers does NestJS support for microservices and how do you bootstrap a microservice?
10How do you connect a NestJS microservice to Apache Kafka?
11How do you handle Kafka message patterns and access message headers and partition info via KafkaContext in NestJS?
12How do you set up gRPC in a NestJS microservice?
13How do you implement a circuit breaker pattern when calling a downstream microservice in NestJS?
14How do you inject and use a ClientProxy to communicate with another microservice in NestJS?
15How do you handle errors in microservice request-response patterns and propagate them to the caller in NestJS?
16How do you implement Kafka consumer groups and what guarantees does partition assignment give you in NestJS?
17How do you implement the outbox pattern with Kafka in NestJS to guarantee exactly-once message delivery?
18How do you implement gRPC streaming including server-side, client-side, and bidirectional streaming in NestJS?
19What is the difference between @EventPattern() and @MessagePattern() in NestJS microservices?
20How do you implement the Saga pattern for distributed transactions across NestJS microservices?
21How do you implement idempotent event handlers to safely handle duplicate message delivery in NestJS?
22How do you implement event sourcing with NestJS microservices?
23How do you implement retry logic with exponential backoff for failed microservice calls in NestJS?
24How do you test a NestJS microservice controller in isolation without a real message broker?
25How do you implement service discovery and load balancing across NestJS microservice instances?
04 / 25

How do you implement manual message acknowledgement with RabbitMQ in NestJS?

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.

Manual ack/nack with dead-letter queue setup
Manual acknowledgement rules:
  1. 1

    noAck: false must be set in the microservice options — otherwise NestJS auto-acks before your handler runs.

  2. 2

    channel.ack(msg) — removes the message from the queue after successful processing.

  3. 3

    channel.nack(msg, false, true) — returns the message to the queue for redelivery.

  4. 4

    channel.nack(msg, false, false) — dead-letters the message instead of requeuing.

  5. 5

    Always ack or nack in a try/finally to prevent message leaks if the handler throws unexpectedly.

Difficulty: 5/10
Topics: RabbitMQ, NestJS microservices, manual acknowledgement

Scenario Questions

0-2 years experience
  1. 1

    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?

  2. 2

    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?

2-5 years experience
  1. 1

    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.

  2. 2

    Explain the trade‑offs between using channel.ack versus channel.nack with the requeue flag when handling high‑volume order events.

5-8 years experience
  1. 1

    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?

  2. 2

    How would you modify your manual ack strategy to support graceful shutdown of a NestJS service without losing in‑flight messages?

8+ years experience
  1. 1

    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?

  2. 2

    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?

Follow-up Questions

  • What would happen if you forget to ack a message?
  • How does NestJS expose the raw channel for manual ack?
  • Can you sketch the code where you conditionally call ack or nack?