当前位置: 首页>>代码示例>>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;未经允许,请勿转载。