You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-143Lines changed: 1 addition & 143 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,131 +163,6 @@ export class AppController {
163
163
164
164
🛠️ Please ensure you're using a compatible setup when working with multiple handlers, as this could result in unexpected behavior.
165
165
166
-
---
167
-
168
-
## RabbitMQ Integration: Messaging Configuration Example
169
-
170
-
---
171
-
172
-
The `MessagingModule` provides out-of-the-box integration with **RabbitMQ**, enabling the use of **AMQP** channels alongside in-memory channels. The configuration below demonstrates **CQRS** by separating command and event buses, ensuring seamless integration of your application with RabbitMQ's flexible messaging capabilities for both **command** and **event handling** + command dispatching.
173
-
174
-
## To make it works for rabbitmq
175
-
We need to install rabbitmq extension for `@nestjstools/messaging`
avoidErrorsForNotExistedHandlers: true, // We can avoid errors if we don't have handler yet for the event
232
-
autoCreate: true,
233
-
}),
234
-
],
235
-
debug: true,
236
-
}),
237
-
],
238
-
})
239
-
exportclassAppModule {}
240
-
```
241
-
242
-
---
243
-
244
-
### Key Features:
245
-
246
-
1.**Multiple Message Buses**:
247
-
- Configure distinct buses for **in-memory**, **commands**, and **events**:
248
-
-`message.bus` (in-memory).
249
-
-`command.message-bus` (AMQP command processing).
250
-
-`event.message-bus` (AMQP event processing).
251
-
252
-
2.**In-Memory Channel**:
253
-
- Simple and lightweight channel suitable for non-persistent messaging or testing purposes.
254
-
255
-
3.**AMQP Channels**:
256
-
- Fully integrated RabbitMQ channel configuration using `AmqpChannelConfig`.
257
-
258
-
4.**Channel Details**:
259
-
-`connectionUri`: Specifies the RabbitMQ server connection.
260
-
-`exchangeName`: The AMQP exchange to publish or consume messages from.
261
-
-`bindingKeys`: Define message routing patterns using wildcards (e.g., `my_app.command.#`).
262
-
-`exchangeType`: Supports RabbitMQ exchange types such as `TOPIC`.
263
-
-`queue`: Specify a RabbitMQ queue to consume messages from.
264
-
-`autoCreate`: Automatically creates the exchange, queue, and bindings if they don’t exist.
265
-
266
-
5.**Error Handling**:
267
-
- Use `avoidErrorsForNotExistedHandlers` in `amqp-event` to gracefully handle missing handlers for event messages.
268
-
269
-
6.**Debug Mode**:
270
-
- Enable `debug: true` to assist in monitoring and troubleshooting messages.
271
-
272
-
This configuration provides a solid foundation for integrating RabbitMQ as part of your messaging system. It facilitates the decoupling of commands, events, and in-memory operations, ensuring reliable and scalable communication across distributed systems.
273
-
274
-
---
275
-
276
-
## Mapping Messages in RabbitMQ Channel
277
-
278
-
### Topic Exchange
279
-
For optimal routing, it's recommended to use routing keys as part of the binding key. For example, if you bind a queue with the key `my_app.command.#`, messages with routing keys like `my_app.command.domain.action` will automatically be routed to that queue. This ensures that any message with a routing key starting with `my_app.command` is directed to the appropriate queue.
280
-
Here's a more concise and clear version of your explanation:
281
-
282
-
### Direct Exchange
283
-
Ensure your queue has defined binding keys, as messages will be routed to queues based on these keys. If no binding keys are defined, the routing key in RabbitMQ will default to the routing key specified in the handler.
284
-
285
-
### Additional
286
-
* You can override message routing using `AmqpMessageOptions`. This allows sending a message to a specified exchange and routing it with a custom key.
| **`name`** | Name of the AMQP channel (e.g., `'amqp-command'`). | |
489
-
| **`connectionUri`** | URI for the RabbitMQ connection, such as `'amqp://guest:guest@localhost:5672/'`. | |
490
-
| **`exchangeName`** | The AMQP exchange name (e.g., `'my_app.exchange'`). | |
491
-
| **`bindingKeys`** | The routing keys to bind to (e.g., `['my_app.command.#']`). | `[]` |
492
-
| **`exchangeType`** | Type of the RabbitMQ exchange (e.g., `TOPIC`). | |
493
-
| **`queue`** | The AMQP queue to consume messages from (e.g., `'my_app.command'`). | |
494
-
| **`autoCreate`** | Automatically creates the exchange, queue, and bindings if they don’t exist. | `true` |
495
-
| **`enableConsumer`** | Enables or disables the consumer for this channel. | `true` |
496
-
| **`avoidErrorsForNotExistedHandlers`** | Avoid errors if no handler is available for the message. | `false` |
497
-
| **`normalizer`** | Set your custom normalizer for messages | |
498
-
499
-
This table provides a structured overview of the **`MessagingModule.forRoot`** configuration, with details about each property within **buses** and **channels** and their corresponding default values.
500
-
501
359
## Creating Your Own Channel and Bus
502
360
This process allows you to define and integrate a custom **Channel** and **MessageBus** for your application, giving you complete flexibility and control over how messages are processed, dispatched, and consumed. Each step provides the necessary building blocks to create your own transport layer with full integration into the `MessagingModule`.
Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "@nestjstools/messaging",
3
-
"version": "2.16.0",
3
+
"version": "2.17.0",
4
4
"description": "Simplifies asynchronous and synchronous message handling with support for buses, handlers, channels, and consumers. Build scalable, decoupled applications with ease and reliability.",
0 commit comments