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


Java BrokerService.addNetworkConnector方法代碼示例

本文整理匯總了Java中org.apache.activemq.broker.BrokerService.addNetworkConnector方法的典型用法代碼示例。如果您正苦於以下問題:Java BrokerService.addNetworkConnector方法的具體用法?Java BrokerService.addNetworkConnector怎麽用?Java BrokerService.addNetworkConnector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.activemq.broker.BrokerService的用法示例。


在下文中一共展示了BrokerService.addNetworkConnector方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createReceiverConnectionFactory

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Override
protected ActiveMQConnectionFactory createReceiverConnectionFactory() throws JMSException {
   try {
      receiveBroker = new BrokerService();
      receiveBroker.setBrokerName("receiveBroker");
      receiveBroker.setUseJmx(false);
      receiveBroker.setPersistent(false);
      receiveBroker.addConnector("tcp://localhost:62002");
      receiveBroker.addNetworkConnector("static:failover:tcp://localhost:62001");
      receiveBroker.start();

      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:62002");
      return factory;
   } catch (Exception e) {
      e.printStackTrace();
      return null;
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:19,代碼來源:TwoBrokerTopicSendReceiveUsingJavaConfigurationTest.java

示例2: createSenderConnectionFactory

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Override
protected ActiveMQConnectionFactory createSenderConnectionFactory() throws JMSException {
   try {
      sendBroker = new BrokerService();
      sendBroker.setBrokerName("sendBroker");
      sendBroker.setUseJmx(false);
      sendBroker.setPersistent(false);
      sendBroker.addConnector("tcp://localhost:62001");
      sendBroker.addNetworkConnector("static:failover:tcp://localhost:62002");
      sendBroker.start();

      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:62001");
      return factory;
   } catch (Exception e) {
      e.printStackTrace();
      return null;
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:19,代碼來源:TwoBrokerTopicSendReceiveUsingJavaConfigurationTest.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 {
   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

示例4: 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

示例5: 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

示例6: setupBroker

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
private BrokerService setupBroker(int thisPort, int otherPort) throws Exception {
  BrokerService broker = new BrokerService();
  broker.setPersistent(false);
  broker.setBrokerName("broker" + thisPort);
  broker.addConnector("tcp://0.0.0.0:" + thisPort);
  broker.addNetworkConnector(String.format("static:(tcp://localhost:%d)", otherPort));
  broker.start();
  broker.waitUntilStarted();
  return broker;
}
 
開發者ID:mnemonic-no,項目名稱:common-services,代碼行數:11,代碼來源:AbstractServiceMessagePerformanceTest.java

示例7: createBroker

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
protected BrokerService createBroker() throws Exception {
   BrokerService broker = new BrokerService();
   broker.setBrokerName(BROKER_NAME);
   configureBroker(broker);
   broker.addConnector("tcp://localhost:61617");
   NetworkConnector networkConnector = broker.addNetworkConnector("static:(tcp://localhost:62617?wireFormat.maxInactivityDuration=500)?useExponentialBackOff=false");
   configureNetworkConnector(networkConnector);
   return broker;
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:10,代碼來源:NetworkBrokerDetachTest.java

示例8: createNetworkedBroker

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
protected BrokerService createNetworkedBroker() throws Exception {
   BrokerService broker = new BrokerService();
   broker.setBrokerName(REM_BROKER_NAME);
   configureBroker(broker);
   broker.getManagementContext().setCreateConnector(false);
   broker.addConnector("tcp://localhost:62617");
   NetworkConnector networkConnector = broker.addNetworkConnector("static:(tcp://localhost:61617?wireFormat.maxInactivityDuration=500)?useExponentialBackOff=false");
   configureNetworkConnector(networkConnector);
   return broker;
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:11,代碼來源:NetworkBrokerDetachTest.java

示例9: createNetworkedBroker

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
protected BrokerService createNetworkedBroker() throws Exception {
   BrokerService broker = new BrokerService();
   broker.setBrokerName("networkedBroker");
   broker.addConnector("tcp://localhost:62617?transport.reuseAddress=true");
   NetworkConnector networkConnector = broker.addNetworkConnector("static:(tcp://localhost:61617?wireFormat.maxInactivityDuration=500)?useExponentialBackOff=false");
   networkConnector.setDuplex(true);
   return broker;
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:9,代碼來源:DuplexNetworkMBeanTest.java

示例10: createBroker

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
protected BrokerService createBroker(String scheme,
                                     String listenPort,
                                     String[] networkToPorts,
                                     HashMap<String, String> networkProps) throws Exception {
   BrokerService broker = new BrokerService();
   broker.getManagementContext().setCreateConnector(false);
   broker.setSslContext(sslContext);
   broker.setDeleteAllMessagesOnStartup(true);
   broker.setBrokerName("Broker_" + listenPort);
   // lazy init listener on broker start
   TransportConnector transportConnector = new TransportConnector();
   transportConnector.setUri(new URI(scheme + "://localhost:" + listenPort));
   List<TransportConnector> transportConnectors = new ArrayList<>();
   transportConnectors.add(transportConnector);
   broker.setTransportConnectors(transportConnectors);
   if (networkToPorts != null && networkToPorts.length > 0) {
      StringBuilder builder = new StringBuilder("static:(failover:(" + scheme + "://localhost:");
      builder.append(networkToPorts[0]);
      for (int i = 1; i < networkToPorts.length; i++) {
         builder.append("," + scheme + "://localhost:" + networkToPorts[i]);
      }
      // limit the reconnects in case of initial random connection to slave
      // leaving randomize on verifies that this config is picked up
      builder.append(")?maxReconnectAttempts=0)?useExponentialBackOff=false");
      NetworkConnector nc = broker.addNetworkConnector(builder.toString());
      if (networkProps != null) {
         IntrospectionSupport.setProperties(nc, networkProps);
      }
   }
   return broker;
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:32,代碼來源:FailoverStaticNetworkTest.java

示例11: testLoopbackOnDifferentUrlScheme

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
@Test
public void testLoopbackOnDifferentUrlScheme() throws Exception {
   final BrokerService brokerServce = new BrokerService();
   brokerServce.setPersistent(false);

   TransportConnector transportConnector = brokerServce.addConnector("nio://0.0.0.0:0");
   // connection filter is bypassed when scheme is different
   final NetworkConnector networkConnector = brokerServce.addNetworkConnector("static:(tcp://" + transportConnector.getConnectUri().getHost() + ":" + transportConnector.getConnectUri().getPort() + ")");

   brokerServce.start();
   brokerServce.waitUntilStarted();

   try {
      Wait.waitFor(new Wait.Condition() {
         @Override
         public boolean isSatisified() throws Exception {
            return 1 == networkConnector.bridges.size();
         }
      });

      final DemandForwardingBridgeSupport loopbackBridge = (DemandForwardingBridgeSupport) networkConnector.bridges.values().iterator().next();
      assertTrue("nc started", networkConnector.isStarted());

      assertTrue("It should get disposed", Wait.waitFor(new Wait.Condition() {
         @Override
         public boolean isSatisified() throws Exception {
            return loopbackBridge.getRemoteBroker().isDisposed();
         }
      }));

      assertEquals("No peer brokers", 0, brokerServce.getBroker().getPeerBrokerInfos().length);

   } finally {
      brokerServce.stop();
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:37,代碼來源:NetworkLoopBackTest.java

示例12: configureProducerBroker

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
protected void configureProducerBroker(BrokerService answer, String uri) throws Exception {
   configureBroker(answer);
   answer.setBrokerName(PRODUCER_BROKER_NAME);
   answer.setMonitorConnectionSplits(false);
   //answer.setSplitSystemUsageForProducersConsumers(true);
   answer.setPersistent(false);
   answer.setDeleteAllMessagesOnStartup(true);
   NetworkConnector connector = answer.addNetworkConnector("static://" + consumerBindAddress);
   //connector.setNetworkTTL(3);
   //connector.setDynamicOnly(true);
   connector.setDuplex(true);
   answer.addConnector(uri);
   answer.setUseShutdownHook(false);
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:15,代碼來源:SimpleNetworkTest.java

示例13: addNetworkBridge

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
protected void addNetworkBridge(BrokerService answer,
                                String bridgeName,
                                String uri,
                                boolean duplex,
                                String destinationFilter) throws Exception {
   NetworkConnector network = answer.addNetworkConnector(uri);
   network.setName(bridgeName);
   network.setDuplex(duplex);
   if (destinationFilter != null && !destinationFilter.equals("")) {
      network.setDestinationFilter(bridgeName);
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:13,代碼來源:FailoverClusterTestSupport.java

示例14: 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

示例15: createAndStartBroker

import org.apache.activemq.broker.BrokerService; //導入方法依賴的package包/類
private BrokerService createAndStartBroker(String name, String addr) throws Exception {
   BrokerService broker = new BrokerService();
   broker.setDeleteAllMessagesOnStartup(true);
   broker.setBrokerName(name);
   broker.addConnector(addr).setDiscoveryUri(new URI(MULTICAST_DEFAULT));
   broker.setUseJmx(false);

   NetworkConnector networkConnector = broker.addNetworkConnector(MULTICAST_DEFAULT);
   networkConnector.setDecreaseNetworkConsumerPriority(true);
   networkConnector.setDynamicOnly(dynamicOnly);
   networkConnector.setNetworkTTL(ttl);
   networkConnector.setSuppressDuplicateTopicSubscriptions(suppressDuplicateTopicSubs);
   networkConnector.setConsumerPriorityBase(BASE_PRIORITY);
   networkConnector.addStaticallyIncludedDestination(new ActiveMQTopic("BeStaticallyIncluded"));

   PolicyMap policyMap = new PolicyMap();
   PolicyEntry policy = new PolicyEntry();
   policy.setDispatchPolicy(dispatchPolicy);
   // the audit will suppress the duplicates as it defaults to true so this test
   // checking for dups will fail. it is good to have it on in practice.
   policy.setEnableAudit(false);
   policyMap.put(new ActiveMQTopic(TOPIC_NAME), policy);
   broker.setDestinationPolicy(policyMap);
   broker.start();

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


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