Message Handler
💬 Defining a Message & Message Handler
Messages are the core units of communication in your system. Each message can have a dedicated handler that processes it when received. This section explains how to define a message and implement a handler.
📨 Define Your Message
A message is a simple class representing the data being sent between services or components:
This message can now be published on a bus and handled by one or more consumers.
🛠️ Define a Message Handler
Handlers process incoming messages. They must implement the IMessageHandler<T>
interface.
🔁 Multiple Routes
🧠 Optional: Use @DenormalizeMessage()
Decorator
@DenormalizeMessage()
DecoratorIf you want NestJS to automatically instantiate the incoming message as a proper class
(rather than just receiving raw JSON), use the @DenormalizeMessage()
decorator:
Last updated