I’ve implemented a CQRS/Event Sourcing application with an external event store and several views. Some views are (for good reasons) managed using a subscribing mode.
I’m wondering how to manage transient error with such views as a network issue or a temporary outage of the underlying database. I can see two possibilities:
- Either catch the error, compensate the event stored in the external event and send back the error to the consumer. Then it would be up to the consumer to manage either reprocessing or display an error in the HMI for example
- Implement a try/catch/retry loop. Each time I face a transient error, I loop in the @EventHandler.
What would be the best scenario? If the first scenario is preferable, I don’t really see how to catch the error. Assuming it was the same thread in charge of the @CommandHandler, the @EventSourcingHandler, and the @EventHandler, I thought I would be able to catch an @EventHandler error when I’m doing an AggregateLifecycle.apply() for example.
Thanks for the help