I am currently looking for NestJS to use as a framework for a new ecommerce project. The goal is to create several loosely coupled services that can communicate with each other using the pub / sub messaging pattern. NestJS offers some great out-of-the-box integrations with tools like Redis, NATS and RabbitMQ. I have read that Kafka is also supported, but that is not yet properly documented.
The problem I have is decision making. After reading a lot of material about event-based systems and how they work, I still don't know exactly which tool to choose.
1) I think I need a news broker who can queue messages to make sure that they (possibly) are delivered to subscribers.
That's because I may have one
CatalogueService the events like
product_created, Services like a
OrderService should also contain a copy of the product data and these products should be up to date. I can't afford to have old prices
OrderService there would be the price calculations. If a service fails, it can be restarted and properly process unprocessed messages in the queue.
2) I think I need a message broker that supports first in, first out (FIFO) queues.
That's because I may have two
product_edited Events that should be processed in the correct order to avoid corrupted data. If a store manager changes a product price twice, the latter price should be considered the most current.
I used the words "I think" before the two requirements because I am not 100% sure that my thinking is correct. Therefore I am curious about what your thoughts and experiences are. Any tips, tricks, or advice would be highly appreciated!