Recall & Review
beginner
What is an event pattern in NestJS event-based communication?
An event pattern is a unique identifier string used to listen for or emit specific events between microservices or modules in NestJS. It helps match events with their handlers.
Click to reveal answer
beginner
How do you define an event handler for a specific event pattern in NestJS?
You use the @EventPattern('patternName') decorator on a method inside a controller or service. This method will run when an event with that pattern is received.
Click to reveal answer
intermediate
What is the difference between @EventPattern and @MessagePattern in NestJS?
@EventPattern listens for events that do not expect a response (fire-and-forget). @MessagePattern listens for messages that expect a response (request-response).
Click to reveal answer
beginner
How do you emit an event with a pattern in NestJS?
You use the ClientProxy's emit method with the event pattern string and the data payload. For example: client.emit('order_created', { id: 1 }).
Click to reveal answer
intermediate
Why are event patterns useful in microservice architectures?
They allow services to communicate asynchronously and loosely coupled by sending and listening to events identified by patterns, improving scalability and flexibility.
Click to reveal answer
Which decorator do you use to listen for an event pattern in NestJS?
✗ Incorrect
The @EventPattern decorator is used to listen for events matching a specific pattern.
What method do you call to emit an event from a NestJS client proxy?
✗ Incorrect
The emit() method sends an event without expecting a response.
What is the main difference between @EventPattern and @MessagePattern?
✗ Incorrect
@EventPattern handles fire-and-forget events; @MessagePattern handles request-response messages.
In NestJS, what does an event pattern usually look like?
✗ Incorrect
Event patterns are string identifiers used to match events with handlers.
Why use event patterns in microservices?
✗ Incorrect
Event patterns enable asynchronous and loosely coupled communication between services.
Explain how to create and handle an event pattern in NestJS.
Think about how you listen and send events using patterns.
You got /4 concepts.
Describe the benefits of using event patterns in a microservice system.
Consider how events help services work independently.
You got /4 concepts.