本文整理汇总了Java中org.apache.activemq.broker.BrokerService.getTransportConnectors方法的典型用法代码示例。如果您正苦于以下问题:Java BrokerService.getTransportConnectors方法的具体用法?Java BrokerService.getTransportConnectors怎么用?Java BrokerService.getTransportConnectors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.broker.BrokerService
的用法示例。
在下文中一共展示了BrokerService.getTransportConnectors方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bridgeBrokers
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws Exception {
List<TransportConnector> remoteTransports = remoteBroker.getTransportConnectors();
List<TransportConnector> localTransports = localBroker.getTransportConnectors();
URI remoteURI;
URI localURI;
if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) {
remoteURI = remoteTransports.get(0).getConnectUri();
localURI = localTransports.get(0).getConnectUri();
// Ensure that we are connecting using tcp
if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:")) {
NetworkBridgeConfiguration config = new NetworkBridgeConfiguration();
config.setBrokerName(localBroker.getBrokerName());
DemandForwardingBridge bridge = new DemandForwardingBridge(config, TransportFactory.connect(localURI), TransportFactory.connect(remoteURI));
bridge.setBrokerService(localBroker);
bridges.add(bridge);
bridge.start();
} else {
throw new Exception("Remote broker or local broker is not using tcp connectors");
}
} else {
throw new Exception("Remote broker or local broker has no registered connectors.");
}
}
示例2: bridgeBrokers
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
@Override
protected NetworkConnector bridgeBrokers(BrokerService localBroker,
BrokerService remoteBroker,
boolean dynamicOnly,
int networkTTL,
boolean conduit,
boolean failover) throws Exception {
String networkDisoveryUrlString = useStaticDiscovery ? "static:(" + remoteBroker.getTransportConnectors().get(0).getPublishableConnectString() + ")?useExponentialBackOff=false" : "multicast://default?group=TESTERIC&useLocalHost=false";
DiscoveryNetworkConnector connector = new DiscoveryNetworkConnector(new URI(networkDisoveryUrlString));
connector.setDynamicOnly(dynamicOnly);
connector.setNetworkTTL(networkTTL);
connector.setDuplex(useDuplexNetworkBridge);
maxSetupTime = 2000;
if (!useStaticDiscovery) {
List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
if (!transportConnectors.isEmpty()) {
TransportConnector mCastTrpConnector = (transportConnectors.get(0));
mCastTrpConnector.setDiscoveryUri(new URI("multicast://default?group=TESTERIC"));
}
}
localBroker.addNetworkConnector(connector);
return connector;
}
示例3: bridgeBrokers
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
@Override
protected NetworkConnector bridgeBrokers(BrokerService localBroker,
BrokerService remoteBroker,
boolean dynamicOnly,
int networkTTL,
boolean conduit,
boolean failover) throws Exception {
List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
URI remoteURI;
if (!transportConnectors.isEmpty()) {
remoteURI = transportConnectors.get(0).getConnectUri();
NetworkConnector connector = new DiscoveryNetworkConnector(new URI("static:" + remoteURI));
connector.setName(localBroker.getBrokerName() + remoteBroker.getBrokerName());
localBroker.addNetworkConnector(connector);
maxSetupTime = 2000;
return connector;
} else {
throw new Exception("Remote broker has no registered connectors.");
}
}
示例4: bridgeAllBrokers
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
protected void bridgeAllBrokers(String groupName,
int ttl,
boolean suppressduplicateQueueSubs,
boolean decreasePriority) throws Exception {
Collection<BrokerItem> brokerList = brokers.values();
for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
BrokerService broker = i.next().broker;
List<TransportConnector> transportConnectors = broker.getTransportConnectors();
if (transportConnectors.isEmpty()) {
broker.addConnector(new URI(AUTO_ASSIGN_TRANSPORT));
transportConnectors = broker.getTransportConnectors();
}
TransportConnector transport = transportConnectors.get(0);
transport.setDiscoveryUri(new URI("multicast://default?group=" + groupName));
NetworkConnector nc = broker.addNetworkConnector("multicast://default?group=" + groupName);
nc.setNetworkTTL(ttl);
nc.setSuppressDuplicateQueueSubscriptions(suppressduplicateQueueSubs);
nc.setDecreaseNetworkConsumerPriority(decreasePriority);
}
// Multicasting may take longer to setup
maxSetupTime = 8000;
}
示例5: restartBroker
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
public BrokerService restartBroker(BrokerService brokerService) throws Exception {
String name = brokerService.getBrokerName();
Map<String, Integer> portMap = new HashMap<String, Integer>();
for (TransportConnector connector : brokerService.getTransportConnectors()) {
portMap.put(connector.getName(), connector.getPublishableConnectURI().getPort());
}
stopBroker(brokerService);
BrokerService broker = createBroker(name, false, portMap);
broker.start();
broker.waitUntilStarted();
return broker;
}
示例6: bridgeAllBrokers
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
@Override
protected void bridgeAllBrokers(String groupName,
int ttl,
boolean suppressduplicateQueueSubs,
boolean decreasePriority) throws Exception {
Collection<BrokerItem> brokerList = brokers.values();
for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
BrokerService broker = i.next().broker;
List<TransportConnector> transportConnectors = broker.getTransportConnectors();
if (transportConnectors.isEmpty()) {
broker.addConnector(new URI(AUTO_ASSIGN_TRANSPORT));
transportConnectors = broker.getTransportConnectors();
}
TransportConnector transport = transportConnectors.get(0);
if (transport.getDiscoveryUri() == null) {
transport.setDiscoveryUri(new URI("multicast://default?group=" + groupName));
}
List<NetworkConnector> networkConnectors = broker.getNetworkConnectors();
if (networkConnectors.isEmpty()) {
broker.addNetworkConnector("multicast://default?group=" + groupName);
networkConnectors = broker.getNetworkConnectors();
}
NetworkConnector nc = networkConnectors.get(0);
nc.setNetworkTTL(ttl);
nc.setSuppressDuplicateQueueSubscriptions(suppressduplicateQueueSubs);
nc.setDecreaseNetworkConsumerPriority(decreasePriority);
}
// Multicasting may take longer to setup
maxSetupTime = 8000;
}
示例7: bridgeBrokers
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws Exception {
List<TransportConnector> remoteTransports = remoteBroker.getTransportConnectors();
List<TransportConnector> localTransports = localBroker.getTransportConnectors();
URI remoteURI;
URI localURI;
if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) {
remoteURI = remoteTransports.get(0).getConnectUri();
localURI = localTransports.get(0).getConnectUri();
// Ensure that we are connecting using tcp
if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:")) {
NetworkBridgeConfiguration config = new NetworkBridgeConfiguration();
config.setBrokerName(localBroker.getBrokerName());
DemandForwardingBridge bridge = new DemandForwardingBridge(config, TransportFactory.connect(localURI), TransportFactory.connect(remoteURI));
bridge.setBrokerService(localBroker);
bridges.add(bridge);
bridge.start();
} else {
throw new Exception("Remote broker or local broker is not using tcp connectors");
}
} else {
throw new Exception("Remote broker or local broker has no registered connectors.");
}
maxSetupTime = 2000;
}
示例8: bridgeBrokers
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
@Override
protected NetworkConnector bridgeBrokers(BrokerService localBroker,
BrokerService remoteBroker,
boolean dynamicOnly,
int networkTTL,
boolean conduit,
boolean failover) throws Exception {
List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
URI remoteURI;
if (!transportConnectors.isEmpty()) {
remoteURI = transportConnectors.get(0).getConnectUri();
if (useSocketProxy) {
socketProxy = new SocketProxy(remoteURI);
remoteURI = socketProxy.getUrl();
}
DiscoveryNetworkConnector connector = new DiscoveryNetworkConnector(new URI("static:(" + remoteURI + "?wireFormat.maxInactivityDuration=" + inactiveDuration + "&wireFormat.maxInactivityDurationInitalDelay=" + inactiveDuration + ")?useExponentialBackOff=false"));
connector.setDynamicOnly(dynamicOnly);
connector.setNetworkTTL(networkTTL);
localBroker.addNetworkConnector(connector);
maxSetupTime = 2000;
if (useDuplexNetworkBridge) {
connector.setDuplex(true);
}
return connector;
} else {
throw new Exception("Remote broker has no registered connectors.");
}
}
示例9: bridgeBrokers
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
protected NetworkConnector bridgeBrokers(BrokerService localBroker,
BrokerService remoteBroker,
boolean dynamicOnly,
int networkTTL,
boolean conduit,
boolean failover) throws Exception {
List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
URI remoteURI;
if (!transportConnectors.isEmpty()) {
remoteURI = transportConnectors.get(0).getConnectUri();
String uri = "static:(" + remoteURI + ")";
if (failover) {
uri = "static:(failover:(" + remoteURI + "))";
}
NetworkConnector connector = new DiscoveryNetworkConnector(new URI(uri));
connector.setName("to-" + remoteBroker.getBrokerName());
connector.setDynamicOnly(dynamicOnly);
connector.setNetworkTTL(networkTTL);
connector.setConduitSubscriptions(conduit);
localBroker.addNetworkConnector(connector);
maxSetupTime = 2000;
return connector;
} else {
throw new Exception("Remote broker has no registered connectors.");
}
}
示例10: bridgeBrokers
import org.apache.activemq.broker.BrokerService; //导入方法依赖的package包/类
@Override
protected NetworkConnector bridgeBrokers(BrokerService localBroker,
BrokerService remoteBroker,
boolean l_dynamicOnly,
int networkTTL,
boolean l_conduit,
boolean l_failover) throws Exception {
List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
URI remoteURI;
if (!transportConnectors.isEmpty()) {
remoteURI = transportConnectors.get(0).getConnectUri();
if (useSocketProxy) {
socketProxy = new SocketProxy(remoteURI);
remoteURI = socketProxy.getUrl();
}
String options = "";
if (failover) {
options = "static:(failover:(" + remoteURI;
} else {
options = "static:(" + remoteURI;
}
if (inactivity) {
options += "?wireFormat.maxInactivityDuration=" + inactiveDuration + "&wireFormat.maxInactivityDurationInitalDelay=" + inactiveDuration + ")";
} else {
options += ")";
}
if (failover) {
options += "?maxReconnectAttempts=0)";
}
options += "?useExponentialBackOff=" + exponentialBackOff;
DiscoveryNetworkConnector connector = new DiscoveryNetworkConnector(new URI(options));
connector.setDynamicOnly(dynamicOnly);
connector.setNetworkTTL(networkTTL);
localBroker.addNetworkConnector(connector);
maxSetupTime = 2000;
if (useDuplexNetworkBridge) {
connector.setDuplex(true);
}
return connector;
} else {
throw new Exception("Remote broker has no registered connectors.");
}
}