Hi all,

When are we gonna switch to JSR-107 listeners?

As I mention in https://community.jboss.org/message/719245#719245, cache entry 
created and modified notifications are not very intuitive if you want to do 
something on cache entry created that you don't wanna do on cache modified, and 
viceversa, and you want to do such thing when isPre=false (the majority of 
times tbh). 

To give you an real example, Hot Rod remote notifications. I want to send a 
different notification when a cache entry is created (=insert) as opposed to 
when cache entry is modified (=update), and of course, I wanna do so *after* 
the event. How do I code this?

Option 1:
- Implement @CacheEntryCreated and in it send a notification for cache entry 
created when isPre=false.
- Implement @CacheEntryModified and in it send a notification for cache entry 
modified when isPre=false.
Problem? If the entry is created, this will generate two notifications (one for 
created, and one for modified) and @CacheEntryModified can only differentiate 
between cache entry created vs modified with isPre=true.

Option 2:
- Implement @CacheEntryModified and in it, check whether value is null. If 
null, entry was created, if not null, entry was modified.
Problem? Only works with isPre=true and this is not good cos you're sending the 
remote notification before the actual event.

Any other solution requires the listener to keep some state which is ugly to 
say the least.

If you have any simpler ideas I might have missed, I'm all ears.

Btw, a similar problems happen with cache entry removed and cache entry 
modified. How do you differentiate between them two when isPre=false?

I haven't checked the JSR-107 listeners yet, but I hope they're more sane in 
this area. 

Cheers,
--
Galder Zamarreño
Sr. Software Engineer
Infinispan, JBoss Cache


_______________________________________________
infinispan-dev mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/infinispan-dev

Reply via email to