當前位置: 首頁>>代碼示例>>Java>>正文


Java BrokerService.getTransportConnectors方法代碼示例

本文整理匯總了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.");
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:27,代碼來源:MultiBrokersMultiClientsUsingTcpTest.java

示例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;
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:25,代碼來源:MulticastDiscoveryOnFaultyNetworkTest.java

示例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.");
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:21,代碼來源:ThreeBrokerStompTemporaryQueueTest.java

示例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;
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:26,代碼來源:JmsMultipleBrokersTestSupport.java

示例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;
}
 
開發者ID:vert-x3,項目名稱:vertx-amqp-bridge,代碼行數:14,代碼來源:ActiveMQTestBase.java

示例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;
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:36,代碼來源:NetworkOfTwentyBrokersTest.java

示例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;
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:29,代碼來源:ThreeBrokerTopicNetworkUsingTcpTest.java

示例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.");
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:29,代碼來源:BrokerQueueNetworkWithDisconnectTest.java

示例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.");
   }

}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:28,代碼來源:JmsMultipleBrokersTestSupport.java

示例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.");
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:46,代碼來源:DurableSubscriberWithNetworkDisconnectTest.java


注:本文中的org.apache.activemq.broker.BrokerService.getTransportConnectors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。