Alachisoft NCache 4.1 - Online Documentation

Custom Notifications

NCache provides the ability to generate custom notifications. A producer application can call a single method that invokes handlers on all the subscribers of the custom notification event. In a clustered environment, custom notifications are convenient means of communication among the participants of the cluster. Even in local environment, a producer consumer style communication between applications is easily achieved using this facility.
Using custom notifications is a two step process. One is a producer end of the notification and other is a consumer end.
  1. To register we simply implement an interface CustomListener on a class:
    import com.alachisoft.ncache.event.*;
    public class CacheEventListner implements CustomListener
    public void customEventOccured(CustomEvent event)
    System.out.println("Custom EVENT :- Custom event is raised for Key[ " + event.getKey() + " ] with value: " + event.getSource().toString());
  2. The custom notification is simply raised by calling:
    Cache _cache = NCache.initializeCache("myCache");
    _cache.raiseCustomEvent("custom-Object", "Custom.Event");
See Also
Copyright © 2005-2012 Alachisoft. All rights reserved.