-
1. Re: Cache event buffering stragetry
manik Mar 4, 2011 5:56 PM (in response to yelin666)Try using asynchronous listeners - @Listener(sync = false)? This uses an executor to dispatch event notifications, and you can tune the executor used. This becomes a natural, built-in buffer. :-)
-
2. Cache event buffering stragetry
yelin666 Mar 8, 2011 10:11 AM (in response to manik)Sorry I probably didn't make it clear. Even with asyncListenerExcecutor tuned, if I have the async listener as follows:
@Listener(sync=false)
public class UpdateEventHandler {
@CacheEntryModified
public void update(CacheEntryModifiedEvent updateEvent) {
}
}
So in the update() method above, that does my event handling, the updateEvent is still for one key/value pair. Basically, our application would like to get notified with a list of values being updated during a period of time, and kick off the processing of the value changes at one time instead of running the processing every time a values changes. Does Infinispan support this natively? If not, what's your recommendation on how we handle the buffering?
-
3. Cache event buffering stragetry
genman Mar 8, 2011 4:24 PM (in response to yelin666)1 of 1 people found this helpfulI'm guessing the best way would be to replace the class/instance that handles the events.
http://docs.jboss.org/infinispan/4.2/apidocs/config.html#ce_global_asyncListenerExecutor
-
4. Cache event buffering stragetry
manik Mar 9, 2011 12:01 PM (in response to yelin666)You could implement a queue in your listener to queue up events, and you could have a separate scheduled executor that periodically flushes the quueue and process the events...
-
5. Cache event buffering stragetry
genman Mar 9, 2011 12:40 PM (in response to manik)^^ Lots of context switches, but it'd work.
-
6. Cache event buffering stragetry
mircea.markus Mar 11, 2011 5:55 AM (in response to manik)1 of 1 people found this helpfulOr not use a scheduled executor, but the calling thread to flush the event queue to the application when it reached a certain threshold or a certain interval has passed. Reduces ctx swithces as well