Caching event sourcing repository and exceptions

51 views
Skip to first unread message

Igor Lovich

unread,
Oct 13, 2016, 2:56:05 PM10/13/16
to Axon Framework Users
Hello,
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

Allard Buijze

unread,
Oct 15, 2016, 3:31:46 PM10/15/16
to Axon Framework Users
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.

Cheers,

Allard

--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Igor Lovich

unread,
Oct 17, 2016, 3:35:26 AM10/17/16
to Axon Framework Users
Thanks
I must have missed the checked/unchecked exception behaviour in the docs.

Reply all
Reply to author
Forward
0 new messages