Java Code Examples for org.apache.activemq.broker.TransportConnector#setDiscoveryUri()

The following examples show how to use org.apache.activemq.broker.TransportConnector#setDiscoveryUri() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MulticastDiscoveryOnFaultyNetworkTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 2
Source File: JmsMultipleBrokersTestSupport.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: DiscoveryUriTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected BrokerService createBroker() throws Exception {
   bindAddress = "tcp://localhost:0";
   BrokerService answer = new BrokerService();
   answer.setPersistent(isPersistent());
   TransportConnector connector = new TransportConnector();
   connector.setUri(new URI(bindAddress));
   connector.setDiscoveryUri(new URI("multicast://default?group=test"));
   answer.addConnector(connector);
   return answer;
}
 
Example 4
Source File: NetworkOfTwentyBrokersTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 5
Source File: JmsDiscoveryProviderTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
protected BrokerService createBroker() throws Exception {

        BrokerService brokerService = new BrokerService();
        brokerService.setBrokerName("localhost");
        brokerService.setPersistent(false);
        brokerService.setAdvisorySupport(false);
        brokerService.setUseJmx(false);

        TransportConnector connector = brokerService.addConnector("amqp://0.0.0.0:0");
        connector.setName("amqp");
        connector.setDiscoveryUri(new URI("multicast://default"));

        return brokerService;
    }
 
Example 6
Source File: AmqpTestSupport.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected void addAdditionalConnectors(BrokerService brokerService, Map<String, Integer> portMap) throws Exception {
    int port = PORT;
    if (portMap.containsKey("amqp")) {
        port = portMap.get("amqp");
    }
    TransportConnector connector = brokerService.addConnector(
        "amqp://127.0.0.1:" + port +
        "?transport.transformer=" + getAmqpTransformer() +
        "&transport.socketBufferSize=" + getSocketBufferSize() +
        "&transport.tcpNoDelay=true" +
        "&ioBufferSize=" + getIOBufferSize());
    connector.setName("amqp");
    if (isAmqpDiscovery()) {
        String uriString = "multicast://default";
        if(getDiscoveryNetworkInterface() != null) {
            uriString += "?networkInterface=" + getDiscoveryNetworkInterface();
        }
        connector.setDiscoveryUri(new URI(uriString));
    }
    port = connector.getPublishableConnectURI().getPort();
    LOG.debug("Using amqp port: {}", port);

    if (isAddOpenWireConnector()) {
        if (portMap.containsKey("openwire")) {
            port = portMap.get("openwire");
        } else {
            port = 0;
        }

        connector = brokerService.addConnector("tcp://0.0.0.0:" + port);
        connector.setName("openwire");

        LOG.debug("Using openwire port: {}", port);
    }
}
 
Example 7
Source File: NetworkLoadTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
protected BrokerService createBroker(int brokerId) throws Exception {
   BrokerService broker = new BrokerService();
   broker.setBrokerName("broker-" + brokerId);
   broker.setPersistent(false);
   broker.setUseJmx(true);
   broker.getManagementContext().setCreateConnector(false);

   final SystemUsage memoryManager = new SystemUsage();
   memoryManager.getMemoryUsage().setLimit(1024 * 1024 * 50); // 50 MB
   broker.setSystemUsage(memoryManager);

   final List<PolicyEntry> policyEntries = new ArrayList<>();
   final PolicyEntry entry = new PolicyEntry();
   entry.setQueue(">");
   entry.setMemoryLimit(1024 * 1024 * 1); // Set to 1 MB
   entry.setPendingSubscriberPolicy(new VMPendingSubscriberMessageStoragePolicy());
   entry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
   policyEntries.add(entry);

   // This is to turn of the default behavior of storing topic messages for retroactive consumption
   final PolicyEntry topicPolicyEntry = new PolicyEntry();
   topicPolicyEntry.setTopic(">");
   final NoSubscriptionRecoveryPolicy noSubscriptionRecoveryPolicy = new NoSubscriptionRecoveryPolicy();
   topicPolicyEntry.setSubscriptionRecoveryPolicy(noSubscriptionRecoveryPolicy);

   final PolicyMap policyMap = new PolicyMap();
   policyMap.setPolicyEntries(policyEntries);
   broker.setDestinationPolicy(policyMap);

   TransportConnector transportConnector = new TransportConnector();
   transportConnector.setUri(new URI("tcp://localhost:" + (60000 + brokerId)));

   transportConnector.setDiscoveryUri(new URI("multicast://default?group=" + groupId));
   broker.addConnector(transportConnector);

   DiscoveryNetworkConnector networkConnector = new DiscoveryNetworkConnector();
   networkConnector.setUri(new URI("multicast://default?group=" + groupId));
   networkConnector.setBridgeTempDestinations(true);
   networkConnector.setPrefetchSize(1);
   broker.addNetworkConnector(networkConnector);

   return broker;
}
 
Example 8
Source File: DiscoveryTransportBrokerTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
protected TransportConnector createConnector() throws Exception, IOException, URISyntaxException {
   TransportConnector x = super.createConnector();
   x.setDiscoveryUri(new URI(getDiscoveryUri()));
   return x;
}
 
Example 9
Source File: DiscoveryTransportBrokerTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
protected TransportConnector createRemoteConnector() throws Exception, IOException, URISyntaxException {
   TransportConnector x = super.createRemoteConnector();
   x.setDiscoveryUri(new URI(getDiscoveryUri()));
   return x;
}