-
1. Re: How to get the entry value in a Listener?
matlach May 14, 2012 11:33 PM (in response to jmfaerman)Hello Julio,
it's not possible to get cache value directly in the event (I don't know why tough, maybe you should fill an enhancement request about it).
but i guess you can access it quite easily like this :
@CacheEntryCreated
public void onCacheEntryCreated(CacheEntryCreatedEvent<String, String> event){
String value = event.getCache().get(event.getKey());
}
for the 'pre' stuff, it's has been already proposed in : https://issues.jboss.org/browse/ISPN-893
feel free to vote for the issue like i already did
hope this helps,
-
2. Re: How to get the entry value in a Listener?
galder.zamarreno May 15, 2012 5:06 AM (in response to matlach)@Mathieu, thanks for the reply, but that won't work: https://docs.jboss.org/author/pages/viewpage.action?pageId=5832860
The big problem with CacheEntryCreated, is that it's not easy to get hold of the entry when the entry has been created.
You have to implement @CacheEntryModified, which also gets fired when the entry is created.
So, how do u differentiate between a create and update with @CacheEntryModified? You can do so when isPre=true, cos event.getValue() would return null if the entry is created.
This area is very fuzzy and as I already highlighted, not very intuitive: http://lists.jboss.org/pipermail/infinispan-dev/2012-February/010272.html
We will be moving towards JSR-107 style notifications soon, so we're deferring any work till then.
-
3. Re: How to get the entry value in a Listener?
galder.zamarreno May 15, 2012 5:07 AM (in response to jmfaerman)1 of 1 people found this helpfulThe isPre() is to allow you to act before, or after the event. Remember that listeners can veto operations, so you could veto a put before the event has actually happened.
-
4. Re: How to get the entry value in a Listener?
jmfaerman May 16, 2012 1:34 PM (in response to galder.zamarreno)Tanks guys, making it clear:
when CacheEntryModified AND pre=false
then the value can be retrieved directly from the event (not from the cache).
And that raises a related question... why is the cache size the same when pre=true and pre=false?
Shouldn't size(pre=false) == size(pre=true) +1 ?
-
5. Re: How to get the entry value in a Listener?
galder.zamarreno May 18, 2012 4:01 AM (in response to jmfaerman)Re: size: You have a point there. Mind creating a JIRA in https://issues.jboss.org/browse/ISPN and attach any test case you might have?
-
6. Re: How to get the entry value in a Listener?
jmfaerman May 19, 2012 8:51 AM (in response to galder.zamarreno)Sure, here it is: https://issues.jboss.org/browse/ISPN-2054
Unfortunately, i do not know ispn code enough yet to solve this, if it is an issue at all, but would be glad do help anyhow.