Questions
1 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?
01 / 25

What is the difference between request-response and event-based (fire-and-forget) message patterns in NestJS microservices?

Request-response uses @MessagePattern() on the handler and client.send() on the caller — the sender waits for a reply returned as an Observable. Event-based uses @EventPattern() on the handler and client.emit() on the caller — the sender fires and forgets with no reply expected or returned.

@MessagePattern vs @EventPattern and their client counterparts
When to use each pattern:
  1. 1

    @MessagePattern + send() — use when the caller needs data back (query operations, synchronous lookups).

  2. 2

    @EventPattern + emit() — use when notifying other services that something happened (domain events).

  3. 3

    send() returns an Observable<T> — always convert with firstValueFrom() or lastValueFrom() for async/await code.

  4. 4

    emit() also returns an Observable — call .subscribe() to trigger the actual send.

  5. 5

    Fire-and-forget decouples services temporally — the emitter does not wait for any consumer to be ready.

Difficulty: 5/10
Topics: request-response, event-based, NestJS microservices

Scenario Questions

0-2 years experience
  1. 1

    You need to call a NestJS microservice to fetch user details and immediately use the result. Which messaging pattern would you choose and why?

  2. 2

    If you publish an event to a NestJS microservice without waiting for a response, what happens on the caller side if the consumer fails?

2-5 years experience
  1. 1

    During a sprint you switched a user‑creation flow from request‑response to fire‑and‑forget. The downstream service sometimes drops messages. How would you diagnose and fix the issue?

  2. 2

    Explain the trade‑offs you’d consider when deciding whether a payment verification step should be request‑response or event‑based in a NestJS system.

5-8 years experience
  1. 1

    Design a NestJS microservice architecture for an order processing pipeline that mixes request‑response for inventory checks and fire‑and‑forget for email notifications. What bottlenecks might appear and how would you mitigate them?

  2. 2

    Your team reports high latency on a request‑response call that could be asynchronous. Walk me through how you’d refactor it to an event‑based pattern while preserving reliability.

8+ years experience
  1. 1

    Across multiple product teams you have both request‑response and fire‑and‑forget communications in NestJS services. How would you establish guidelines to ensure consistency, observability, and fault tolerance at the organization level?

  2. 2

    A legacy system uses request‑response for all inter‑service calls. You need to migrate to an event‑driven architecture without downtime. Outline the migration strategy and the risks you’d monitor.

Follow-up Questions

  • How does error handling differ between the two patterns?
  • What impact does each pattern have on service latency and throughput?
  • Can you mix both patterns in the same microservice architecture, and why would you?