How should I handle exception without rollback in domain model?

We would like to handle out of order events in Axon. When any such event arrives, we generate an ignore command for this event and persist in the event store, once this is done, we also want to throw an exception so that we can inform the users that the event was out of order.
We try using sendAndWait method of CommandGateway and catch CommandExecutionException, but this turns out to be not persisting the ignore event and just throw exception.

Hi Neha,

I’m not sure if I understand the problem correctly. Events are delivered normally delivered in-order. If you have events delivered out of order, there might be a configuration problem.
From the second part of your message, it seems like you want to be able to throw an exception and still commit the changes? By default, the Unit of Work is rolled back on unchecked exception. This behavior can be modified by changing the RollbackConfiguration defined on the CommandBus. You can specify for each type of exception whether you want to commit or rollback.

Hope this helps.
Cheers,

Hi Allard,

Its not axon’s configuration which is causing events to be out of order but our system gets events from multiple places and there is a possibility for those events to come in any order as per the business model.
I will try the Rollback configuration you mentioned to achieve persisting the event even on exception.

Thanks,
Neha