Caching event sourcing repository and exceptions

  We are using the caching es repository ( axon 2.4.3) and discovered that it evicts an aggregate from the cache on any Exception during command processing.
  Since we use exceptions to abort processing (e.g. if the business rule validation fails) this presents somewhat of an issue as subsequent requests will hit the db.
  While I understand why it would be necessary to evict from the cache for some exceptions e.g. optimistic lock etc.
Should it really evict for all exceptions?

It doesn't look like there is a way to parameterize this behaviour. Any suggestions other than copying and modifying the axon implem?

Thank you

Hi Igor,

actually, the cache entry is evicted when the Unit of Work is rolled back. And because it rolls back, the state of the Aggregate cannot be assumed to be correct anymore.

By default, the Unit of Work is rolled back on unchecked exceptions and committed on checked exceptions. You can change this by defining a different RollbackConfiguration on your Command Bus.



  I must have missed the checked/unchecked exception behaviour in the docs.