Java Code Examples for org.apache.activemq.broker.BrokerService#setTransportConnectors()

The following examples show how to use org.apache.activemq.broker.BrokerService#setTransportConnectors() . 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: JMSEndpointSuspensionViaVFSTest.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private boolean startBroker() {
    try {
        log.info("JMSServerController: Preparing to start JMS Broker: ");
        broker = new BrokerService();
        // configure the broker

        broker.setBrokerName("myBroker1");
        log.info(broker.getBrokerDataDirectory());
        broker.setDataDirectory(System.getProperty(FrameworkConstants.CARBON_HOME) + File.separator + broker
                .getBrokerDataDirectory());
        broker.setTransportConnectors(getTCPConnectors());
        broker.setPersistent(true);

        broker.start();
        log.info("JMSServerController: Broker is Successfully started. continuing tests");
        return true;
    } catch (Exception e) {
        log.error("JMSServerController: There was an error starting JMS broker: ", e);
        return false;
    }
}
 
Example 2
Source File: JMSEndpointSuspensionViaVFSTest.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private boolean startBroker() {
    try {
        log.info("JMSServerController: Preparing to start JMS Broker: " );
        broker = new BrokerService();
        // configure the broker

        broker.setBrokerName("myBroker1");
        log.info(broker.getBrokerDataDirectory());
        broker.setDataDirectory(System.getProperty(FrameworkConstants.CARBON_HOME) +
                File.separator + broker.getBrokerDataDirectory());
        broker.setTransportConnectors(getTCPConnectors());
        broker.setPersistent(true);

        broker.start();
        log.info("JMSServerController: Broker is Successfully started. continuing tests");
        return true;
    } catch (Exception e) {
        log.error(
                "JMSServerController: There was an error starting JMS broker: ", e);
        return false;
    }
}
 
Example 3
Source File: CheckDuplicateMessagesOnDuplexTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private void createLocalBroker() throws Exception {
   localBroker = new BrokerService();
   localBroker.setBrokerName("LOCAL");
   localBroker.setUseJmx(true);
   localBroker.setSchedulePeriodForDestinationPurge(5000);
   ManagementContext managementContext = new ManagementContext();
   managementContext.setCreateConnector(false);
   localBroker.setManagementContext(managementContext);
   PersistenceAdapter persistenceAdapter = persistenceAdapterFactory("target/local");
   localBroker.setPersistenceAdapter(persistenceAdapter);
   List<TransportConnector> transportConnectors = new ArrayList<>();
   DebugTransportFactory tf = new DebugTransportFactory();
   TransportServer transport = tf.doBind(URI.create("nio://127.0.0.1:23539"));
   TransportConnector transportConnector = new TransportConnector(transport);
   transportConnector.setName("tc");
   transportConnector.setAuditNetworkProducers(true);
   transportConnectors.add(transportConnector);
   localBroker.setTransportConnectors(transportConnectors);
}
 
Example 4
Source File: JMSBroker.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to set initial broker configurations.
 *
 * @throws Exception if there is an error setting TransportConnectors
 */
private void setInitialConfigurations() throws Exception {
    log.info("JMSServerController: Preparing to start JMS Broker: " + serverName);
    broker = new BrokerService();
    broker.setBrokerName(serverName);
    log.info(broker.getBrokerDataDirectory());
    broker.setDataDirectory(
            System.getProperty(FrameworkConstants.CARBON_HOME) + File.separator + broker.getBrokerDataDirectory());
    broker.setTransportConnectors(transportConnectors);
    broker.setPersistent(true);
}
 
Example 5
Source File: JMSBroker.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to set initial broker configurations.
 *
 * @throws Exception if there is an error setting TransportConnectors
 */
private void setInitialConfigurations() throws Exception {
    log.info("JMSServerController: Preparing to start JMS Broker: " + serverName);
    broker = new BrokerService();
    broker.setBrokerName(serverName);
    log.info(broker.getBrokerDataDirectory());
    broker.setDataDirectory(System.getProperty(FrameworkConstants.CARBON_HOME) + File.separator
            + broker.getBrokerDataDirectory());
    broker.setTransportConnectors(transportConnectors);
    broker.setPersistent(true);
}
 
Example 6
Source File: FailoverStaticNetworkTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
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;
}