Class JGroupsChannel

  • All Implemented Interfaces:
    org.jgroups.MembershipListener, org.jgroups.MessageListener, org.jgroups.Receiver

    public class JGroupsChannel
    extends org.jgroups.ReceiverAdapter
    JGroupsChannel establishes a connection to a JGroups cluster. It sends/receives over that and forwards the received messages to the appropriate Broadcaster on its node. Best practice would have only 1 of these per Atmosphere application. Each JGroupsFilter instance has a reference to the singleton JGroupsChannel object and registers its broadcaster via the addBroadcaster() method.
    Author:
    westraj
    • Constructor Summary

      Constructors 
      Constructor Description
      JGroupsChannel​(org.jgroups.JChannel jchannel, java.lang.String clusterName)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addBroadcaster​(org.atmosphere.cpr.Broadcaster broadcaster)
      Adds/replaces the broadcaster to the JGroupsChannel
      void destroy()
      Shutdown the cluster.
      void init()
      Connect to the cluster
      void receive​(org.jgroups.Message jgroupMessage)
      void removeBroadcaster​(org.atmosphere.cpr.Broadcaster broadcaster)
      Removes the broadcaster from the JGroupsChannel
      void send​(java.lang.String topic, java.lang.Object message)
      Called from a ClusterBroadcastFilter filter() method to send the message over to other Atmosphere cluster nodes
      • Methods inherited from class org.jgroups.ReceiverAdapter

        block, getState, setState, suspect, unblock, viewAccepted
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JGroupsChannel

        public JGroupsChannel​(org.jgroups.JChannel jchannel,
                              java.lang.String clusterName)
        Constructor
        Parameters:
        jchannel - unconnected JGroups JChannel object
        clusterName - name of the group to connect the JChannel to
    • Method Detail

      • init

        public void init()
                  throws java.lang.Exception
        Connect to the cluster
        Throws:
        java.lang.Exception
      • destroy

        public void destroy()
        Shutdown the cluster.
      • receive

        public void receive​(org.jgroups.Message jgroupMessage)
        Specified by:
        receive in interface org.jgroups.MessageListener
        Overrides:
        receive in class org.jgroups.ReceiverAdapter
      • send

        public void send​(java.lang.String topic,
                         java.lang.Object message)
        Called from a ClusterBroadcastFilter filter() method to send the message over to other Atmosphere cluster nodes
        Parameters:
        topic -
        message -
      • addBroadcaster

        public void addBroadcaster​(org.atmosphere.cpr.Broadcaster broadcaster)
        Adds/replaces the broadcaster to the JGroupsChannel
        Parameters:
        broadcaster -
      • removeBroadcaster

        public void removeBroadcaster​(org.atmosphere.cpr.Broadcaster broadcaster)
        Removes the broadcaster from the JGroupsChannel
        Parameters:
        broadcaster -