// Get JMS Broker
BrokerService broker = ClusterManager.getInstance().getBrokerService();
// Peer Network Connection
NetworkConnector con = null;
try {
log.debug("[PeerService] Connecting with Peer Cluster on " + url);
con = broker.addNetworkConnector(url);
if (con==null) {
throw new Exception("NetworkConnector Null");
}
// Configure Network Connection
con.addStaticallyIncludedDestination(new ActiveMQTopic("nebula.cluster.service.topic"));
con.setConduitSubscriptions(false);
con.setDynamicOnly(true); // Do not forward if no consumers
con.addExcludedDestination(new ActiveMQQueue("nebula.cluster.registration.queue"));
con.addExcludedDestination(new ActiveMQQueue("nebula.cluster.services.facade.queue"));
con.setNetworkTTL(128); // Default TTL
con.setDuplex(true); // Full-duplex communication
con.start();
peers.put(url, con);
log.info("[PeerService] Connected with Peer Cluster on " + url);
// Notify Event Hooks
ServiceMessage message = new ServiceMessage(url, ServiceMessageType.PEER_CONNECTION);
ServiceEventsSupport.getInstance().onServiceMessage(message);
} catch (Exception e) {
log.warn("[PeerService] Unable to connect with Cluster " + url, e);
if (con!=null) { // If Connection was created
try {
// Try to Stop
con.stop();
} catch (Exception e1) {
log.warn("[PeerService] Unable to Stop Connector " + url, e1);
}
broker.removeNetworkConnector(con);
}