Hello,
In current implementation we have requirements that before/after some state changes (objectCreated|objectDeleted|…) we need to perform actions. e.g. publish commands and depending on their result -> continue current unit of work|rollback|send compensating command
I found that I can do this with UnitOfWork#onCommit #onPrepareCommit #afterCommit…
I was doing this in command’s MessageHandlerInterceptor, but then I realised that I should preform actions based on events instead of commands (right?). So I’d like to move this functionality elsewhere.
when I can send compensating task, then it could be @EventHandler method, but when I want to rollback current unit of work (don’t allow to commit changes made by initiating command) where should I register the handler?
Or is there any “best practices” advice how to do this kind of operations?
Thanks
Lukas