
public class JGroupsBusMessagingLayer extends Object implements BusMessagingLayer, ProvidesDisconnectionInformation
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_UDP_PROTOCOL |
ANONYMOUS_AGENT| Constructor and Description |
|---|
JGroupsBusMessagingLayer()
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMessageListener(String agentName,
BusMessageForwarder forwarder,
Bus... buses)
Sets up callback configuration for a topic and subsystem.
|
void |
close()
Close the Transport Layer.
|
void |
closeFor(String agentName,
Bus... buses)
close entry points for a bus for an agent.
|
static org.jgroups.conf.XmlConfigurator |
createXmlConfiguratorForBus(String xmlConfigurationFile,
Properties properties,
String bus)
Creates an XmlConfiguration object for a given bus.
|
BusMembershipListener |
getBusMembershipListener(Bus bus) |
List<String> |
getConnectedNames(Bus bus)
gets a list of agent names connected to a bus.
|
void |
register(String agentName,
Bus... buses)
Creates low level communication entry points for a subsystem.
|
void |
removeMessageListener(String agentName,
BusMessageForwarder forwarder,
Bus... buses)
Removes a message listener from the forwarder list.
|
<T extends BusPayload> |
sendMessage(String senderAgent,
Bus<T> bus,
T message,
String... destinations)
sends a message on a bus: note that BusMessage should have sender and
destination information but it is not the role of the communication layer
to parse destination information such as "subsystem1, subsystem2" or
"subsystem3/module"a.
|
void |
setMembershipListener(BusMembershipListener listener,
Bus... buses)
optional operation.
|
public static final String DEFAULT_UDP_PROTOCOL
@Deprecated public JGroupsBusMessagingLayer()
public void register(String agentName, Bus... buses) throws IOException
BusMessagingLayerregister in interface BusMessagingLayeragentName - name of the sending/receiving point as will be known by transport
null or empty string means that the local agent will receive all messages
(whatever the destination of the message is : "anonymous agent")
if an agent with same name is already locally registered for these buses nothing happens (the call is
idempotent), but if another agent has the same name on the network a DuplicateBusNameException
may be fired (this is an optional behaviour) but this exception is reported only to the corresponding
BusMembershipListenerbuses - list of buses we want to connect to, if empty connects to all busesIOException - if connection impossible,public static org.jgroups.conf.XmlConfigurator createXmlConfiguratorForBus(String xmlConfigurationFile, Properties properties, String bus)
xmlConfigurationFile - The name of the xml file to be loadedproperties - The properties object to be used to overwrite the xml filebus - The bus for which the properties are scannedpublic void closeFor(String agentName, Bus... buses)
BusMessagingLayercloseFor in interface BusMessagingLayeragentName - (if empty voids the "anonymous" agent capabilitiesbuses - if empty all registered buses for the agent will be closedpublic void close()
throws IOException
BusMessagingLayerclose in interface Closeableclose in interface AutoCloseableclose in interface BusMessagingLayerIOExceptionpublic <T extends BusPayload> void sendMessage(String senderAgent, Bus<T> bus, T message, String... destinations) throws IOException
BusMessagingLayerThe message will be sent to all destinations plus to all the "anonymous" agents
sendMessage in interface BusMessagingLayersenderAgent - which agent is supposed to be the initiator of the message
(anonymous agents are not supposed to send message: that may fire an exception)destinations - could be empty (means broadcast) of a single "" or a single"*" (again means broadcast)
or a list of destinations (DO NOT use things such as "*", "dest1", "dest2" : this will not work!)IOException - this could have a list of causes if some destinations fail.
as much as possible implementers will ensure that all correct destinationa are adressed:
if some fail it is not mandatory to report with a special subclass of IOexception that lists all destination
that failed.DestinationsExceptionpublic void addMessageListener(String agentName, BusMessageForwarder forwarder, Bus... buses)
BusMessagingLayeraddMessageListener in interface BusMessagingLayeragentName - if empty adds a forwarder to "anonymous" agent that receives all messagesforwarder - code that handles the incoming messagesbuses - if empty the forwarder listens to all buses.public void removeMessageListener(String agentName, BusMessageForwarder forwarder, Bus... buses)
BusMessagingLayerremoveMessageListener in interface BusMessagingLayerbuses - if empty forwarder is removed from all busespublic void setMembershipListener(BusMembershipListener listener, Bus... buses)
ProvidesDisconnectionInformationsetMembershipListener in interface ProvidesDisconnectionInformationlistener - can be null if we want to deregister a previous listenerbuses - if empty register to all busespublic List<String> getConnectedNames(Bus bus)
getConnectedNames in interface ProvidesDisconnectionInformationbus - public BusMembershipListener getBusMembershipListener(Bus bus)
getBusMembershipListener in interface ProvidesDisconnectionInformationCopyright © 2015 LSST. All rights reserved.