Package org.atmosphere.plugin.jgroups
Class JGroupsChannel
- java.lang.Object
-
- org.jgroups.ReceiverAdapter
-
- org.atmosphere.plugin.jgroups.JGroupsChannel
-
- All Implemented Interfaces:
org.jgroups.MembershipListener,org.jgroups.MessageListener,org.jgroups.Receiver
public class JGroupsChannel extends org.jgroups.ReceiverAdapterJGroupsChannel 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 voidaddBroadcaster(org.atmosphere.cpr.Broadcaster broadcaster)Adds/replaces the broadcaster to the JGroupsChannelvoiddestroy()Shutdown the cluster.voidinit()Connect to the clustervoidreceive(org.jgroups.Message jgroupMessage)voidremoveBroadcaster(org.atmosphere.cpr.Broadcaster broadcaster)Removes the broadcaster from the JGroupsChannelvoidsend(java.lang.String topic, java.lang.Object message)Called from a ClusterBroadcastFilter filter() method to send the message over to other Atmosphere cluster nodes
-
-
-
Method Detail
-
init
public void init() throws java.lang.ExceptionConnect to the cluster- Throws:
java.lang.Exception
-
destroy
public void destroy()
Shutdown the cluster.
-
receive
public void receive(org.jgroups.Message jgroupMessage)
- Specified by:
receivein interfaceorg.jgroups.MessageListener- Overrides:
receivein classorg.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-
-
-