Description
It is not reasonable to use In-memory eventBus for doing cqrs in production.
Instead, we should use some message broker system for eventBus like Kafka.
There are some questions in my mind.
-
Although we could somehow switch the defaultPubSub to other mechanism like Kafka or something else, the underlying is using Rxjs observer pattern. What I currently do is switch the defaultPubSub to my customised PubSub. Run a kafka consumer in the defaultPubSub, and what I do inside is just
subject$.next(event)
. To do so, I need to guarantee the event-handler have successfully response to the event then commit the offset, but how could I do that without changing the code in EventBus? -
I would like to implement a Saga Orchestrator pattern that to manage distributed transaction. But the saga is implemented by observer pattern as well. Again I need to guarantee the saga have successfully response to the event then commit the offset, how could I do that? I think Saga is just like a special kind of aggregate, which should have its own state as well. So saga is also just an event-handler that it could make use of commandBus to send command.
So, to summarise, is that using RxJs a correctly way to implement cqrs system? And I think really need some "production" level example that using nestjs/cqrs.
Thanks.