<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 28 Jan 2013, at 08:11, Dan Berindei &lt;<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><p dir="ltr"><br>
On 25 Jan 2013 23:26, "Vladimir Blagojevic" &lt;<a href="mailto:vblagoje@redhat.com" target="_blank">vblagoje@redhat.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hey,<br>
&gt;<br>
&gt; I figured out why cache listeners notifications were not fired. We have<br>
&gt; to add listener *after* cache.start() has been called. If listener is<br>
&gt; added before start it will not be registered.<br>
&gt;</p><p dir="ltr">This doesn't sound right... DefaultCacheManager calls cache.start() automatically, so you should never have to call it explicitly.</p><p dir="ltr">Looking at the code, the listener should be registered even if the cache wasn't started yet (e.g. ListenerRegistrationTest never calls start()). The only odd thing is that if you stop a cache, all the listeners are lost. Maybe that's what happened in your case?</p><p dir="ltr">&gt; That aside I found some problems mapping our events to jsr 107 events.<br>
&gt; The problem is specifically with JSR107 CacheEntryCreatedListener and<br>
&gt; CacheEntryExpiredListener.<br>
&gt;<br>
&gt; The first one is not easy to implement because we need both key/value<br>
&gt; pair for jsr listener and our CacheEntryCreatedEvent does not provide<br>
&gt; value. I found some references where people used CacheEntryModified<br>
&gt; instead with pre being null and post being value to detect new entry in<br>
&gt; cache. In that case listener translator class would have to keep state<br>
&gt; and track pre(true/false) for CacheEntryModified, right? Any other way<br>
&gt; to do it?<br>
&gt;</p><p>You could add an interceptor to trigger your events, without using the cache's notifications&nbsp; at all. <br></p><p>If you're ok with changing the core, you could add a getValue() method to CacheEntryCreatedEvent, and an isCreated() method to CacheEntryModifiedEvent (as I suppose you don't want to call the updates listener when an entry is created). Both changes should be backwards-compatible.<br></p></div></blockquote><div>That could work.</div><blockquote type="cite"><div dir="ltr"><p>

</p><p dir="ltr"><br>
&gt; The second I have no idea how to implement as we do not have<br>
&gt; CacheEntryExpired event. True, spec is not rigorous that such an event<br>
&gt; has to be fired immediately after an entry has expired but eventually<br>
&gt; (which might be on access). Either way, I am all ears on suggestions how<br>
&gt; to implement this one.<br>
&gt;</p><p>I guess @CacheEntryEvicted/@CacheEntriesEvicted would be the closest thing we have in Infinispan. But you can't check in the listener if the entry was evicted because it expired or because there wasn't enough space in the data container (yet).<br></p></div></blockquote><div>There could definitely be something clever we could do here. &nbsp;Adding the (expired or evicted) entry to a queue for later notification. &nbsp;But that would definitely need to be something we explicitly enable rather than have running all the time, since it kinda defeats the purpose of evicting something to save memory only to have it put in a different queue elsewhere until an event is fired.</div><blockquote type="cite"><div dir="ltr"><p>

</p><p>Come to think of it, if an entry is evicted because of size constraints, there isn't any way to keep track of its expiration time and invoke the expiration listener on access either. Is the expiration event mandatory in the JSR?</p></div></blockquote><div>Yes it is. &nbsp;But it doesn't need to be accurate. &nbsp;<a href="https://github.com/jsr107/jsr107spec/blob/master/src/main/java/javax/cache/event/CacheEntryExpiredListener.java">https://github.com/jsr107/jsr107spec/blob/master/src/main/java/javax/cache/event/CacheEntryExpiredListener.java</a></div><br><blockquote type="cite"><div dir="ltr"><p>

</p><p dir="ltr">Cheers</p><p>Dan</p><p><br>
</p>
</div>
_______________________________________________<br>infinispan-dev mailing list<br><a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/infinispan-dev</blockquote></div><br><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>--</div><div>Manik Surtani</div><div><a href="mailto:manik@jboss.org">manik@jboss.org</a></div><div><a href="http://twitter.com/maniksurtani">twitter.com/maniksurtani</a></div><div><br></div><div><div>Platform Architect, JBoss Data Grid</div><div><a href="http://red.ht/data-grid">http://red.ht/data-grid</a></div></div></div></span></div></span></div></span>
</div>
<br></body></html>