Look at the @ViewChanged annotation, with which you can annotate methods on registered @CacheListener objects so that they are invoked whenever a change in the cluster membership is detected.
Thank you for guidance.
But i want to listen to own computer's events also,
When i disable Network, so application shows exception stack, which i think handled interally, I want to catch it in my code [or listen to events].
You can implement the org.jgroups.ChannelListener interface (http://www.jgroups.org/javagroupsnew/docs/javadoc/org/jgroups/ChannelListener.html ). You register your impl with the org.jgroups.Channel used by the cache via the Channel.add/removeChannelListener(ChannelListener listener) methods. You get a ref to the channel from a started cache via cache.getConfiguration().getRuntimeConfig().getChannel().
As with all JGroups callbacks, be careful not to execute long running tasks in the thread that invokes the listener callbacks. And don't try to use that thread to do anything that results in sending messages to the cluster.
I added as you said, but no event is fired.
I am using GossipRouter, When i stop gossip router, i get these error printed internally. But event is not fired and executed.
2008-12-16 09:05:01,553 ERROR [GossipClient] (Timer-4,220.127.116.11:7800) exception connecting to host 18.104.22.168:5555
2008-12-16 09:05:02,756 ERROR [GossipClient] (Timer-1) exception connecting to host 22.214.171.124:5555
I am using TCP and GossipRouter.
No event is getting fired.
I change it to UDP and still no event is fired.
But Guess what? when i disconnect network of one UDP app instance, and at the time of connection of network , event got fired.
?????? I am getting more and more confused................