Modifications are only rolledback when there're transactions and for such notifications, there's @TransactionCompleted and its TransactionCompletedEvent that contains:
/** * @return if <tt>true</tt>, the transaction completed by committing successfully. If <tt>false</tt>, the transaction * completed with a rollback. */ boolean isSuccessful();
Do you mean something like i should accumulate events, clear the accumulating list on TransactionCompletedEvent, and re-fire the accumulated events on TransactionCompletedEvent if isSuccessful is true?
I have seen this workaround mentionned in the PojoCacheListener javadoc, but i don't understand why JBPC doesn't already do this by himself.
I can't think of a use case where you would need to be notified of rolled back events.
The CacheListener is a local observer: it sees changes to the local copy of the cache.
If a transaction is started on the "master" node (master for a given interaction, otherwise nodes need not be symmetric), and it is rolled back, changes are not replicated to the slave nodes.
Thus on slave nodes, the CacheListener is not notified of any change on rollback.
So the only problem is that the master node's CacheListener IS notified even in case of rollback.
So you don't need the workaround if, on the master node, you don't need the notification.
I'm not sure what your problem is with the master node. If you implement @TransactionRegistered you can know when a transaction started and any @NodeModified events you receive between when @TransactionRegistered was called and when @TransactionCompleted is received, you know these are not final unless you receive TransactionCompletedEvent.isSuccessful=true, otherwise you should be able to discard them.