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

The following examples show how to use org.apache.activemq.broker.TransportConnector#setName() . 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: 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 2
Source File: FailoverClusterTestSupport.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected void addTransportConnector(BrokerService brokerService,
                                     String connectorName,
                                     String uri,
                                     boolean clustered) throws Exception {
   TransportConnector connector = brokerService.addConnector(uri);
   connector.setName(connectorName);
   if (clustered) {
      connector.setRebalanceClusterClients(true);
      connector.setUpdateClusterClients(true);
      connector.setUpdateClusterClientsOnRemove(true);
   } else {
      connector.setRebalanceClusterClients(false);
      connector.setUpdateClusterClients(false);
      connector.setUpdateClusterClientsOnRemove(false);
   }
}
 
Example 3
Source File: JMSBroker.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor to defined broker transport
 *
 * @param serverName    name for the server
 * @param configuration Transport configurations which should expose by the server
 */
public JMSBroker(String serverName, JMSBrokerConfiguration configuration) {
    this.serverName = serverName;
    this.transportConnectors = new ArrayList<TransportConnector>();
    TransportConnector connector = new TransportConnector();
    connector.setName("tcp");
    try {
        connector.setUri(new URI(configuration.getProviderURL()));
    } catch (URISyntaxException e) {
        log.error("Invalid URI", e);
    }
    transportConnectors.add(connector);

}
 
Example 4
Source File: JMSEndpointSuspensionViaVFSTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private List<TransportConnector> getTCPConnectors() {
    //setting the tcp transport configurations
    List<TransportConnector> tcpList = new ArrayList<>();
    TransportConnector tcp = new TransportConnector();
    tcp.setName("tcp");
    try {
        tcp.setUri(new URI("tcp://127.0.0.1:61816"));
    } catch (URISyntaxException e) {
        log.error("Error while setting tcp uri :tcp://127.0.0.1:61816", e);
    }
    tcpList.add(tcp);
    return tcpList;
}
 
Example 5
Source File: JMSBroker.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor to defined broker transport
 *
 * @param serverName    name for the server
 * @param configuration Transport configurations which should expose by the server
 */
public JMSBroker(String serverName, JMSBrokerConfiguration configuration) {
    this.serverName = serverName;
    this.transportConnectors = new ArrayList<TransportConnector>();
    TransportConnector connector = new TransportConnector();
    connector.setName("tcp");
    try {
        connector.setUri(new URI(configuration.getProviderURL()));
    } catch (URISyntaxException e) {
        log.error("Invalid URI", e);
    }
    transportConnectors.add(connector);

}
 
Example 6
Source File: JMSEndpointSuspensionViaVFSTest.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private List<TransportConnector> getTCPConnectors() {
    //setting the tcp transport configurations
    List<TransportConnector> tcpList = new ArrayList<>();
    TransportConnector tcp = new TransportConnector();
    tcp.setName("tcp");
    try {
        tcp.setUri(new URI("tcp://127.0.0.1:61816"));
    } catch (URISyntaxException e) {
        log.error("Error while setting tcp uri :tcp://127.0.0.1:61816", e);
    }
    tcpList.add(tcp);
    return tcpList;
}
 
Example 7
Source File: NIOSSLBasicTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public BrokerService createBroker(String connectorName, String connectorString) throws Exception {
   BrokerService broker = new BrokerService();
   broker.setPersistent(false);
   broker.setUseJmx(false);
   TransportConnector connector = broker.addConnector(connectorString);
   connector.setName(connectorName);
   broker.start();
   broker.waitUntilStarted();
   return broker;
}
 
Example 8
Source File: AMQStackOverFlowTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private BrokerService createBrokerService(final String brokerName,
                                          final String uri1,
                                          final String uri2) throws Exception {
   final BrokerService brokerService = new BrokerService();

   brokerService.setBrokerName(brokerName);
   brokerService.setPersistent(false);
   brokerService.setUseJmx(true);

   final SystemUsage memoryManager = new SystemUsage();
   //memoryManager.getMemoryUsage().setLimit(10);
   brokerService.setSystemUsage(memoryManager);

   final List<PolicyEntry> policyEntries = new ArrayList<>();

   final PolicyEntry entry = new PolicyEntry();
   entry.setQueue(">");
   //entry.setMemoryLimit(1);
   policyEntries.add(entry);

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

   final TransportConnector tConnector = new TransportConnector();
   tConnector.setUri(new URI(uri1));
   tConnector.setName(brokerName + ".transportConnector");
   brokerService.addConnector(tConnector);

   if (uri2 != null) {
      final NetworkConnector nc = new DiscoveryNetworkConnector(new URI("static:" + uri2));
      nc.setBridgeTempDestinations(true);
      nc.setBrokerName(brokerName);
      //nc.setPrefetchSize(1);
      brokerService.addNetworkConnector(nc);
   }

   return brokerService;
}
 
Example 9
Source File: ActiveMQTestBase.java    From vertx-proton with Apache License 2.0 5 votes vote down vote up
protected void addAdditionalConnectors(BrokerService brokerService, Map<String, Integer> portMap) throws Exception {
  int port = PORT;
  if (portMap.containsKey(AMQP_CONNECTOR_NAME)) {
    port = portMap.get(AMQP_CONNECTOR_NAME);
  }
  TransportConnector connector = brokerService
      .addConnector("amqp://0.0.0.0:" + port + "?transport.transformer=" + getAmqpTransformer()
          + "&transport.socketBufferSize=" + getSocketBufferSize() + "&ioBufferSize=" + getIOBufferSize());
  connector.setName(AMQP_CONNECTOR_NAME);

  port = connector.getPublishableConnectURI().getPort();
  if (LOG.isDebugEnabled()) {
    LOG.debug("Using amqp port: " + port);
  }
}
 
Example 10
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 11
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 12
Source File: MiniBrokerConfiguration.java    From maestro-java with Apache License 2.0 4 votes vote down vote up
/**
 * Configure the provider
 * @param provider the provider to configure
 */
public void configure(ActiveMqProvider provider) {
    logger.info("Configuring the provider");
    provider.setUri(CONNECTOR);


    /*
      Configure the broker to use the Maven's target directory (ie.:
      ${basedir}/target/test-classes) as the data directory for the
      broker. Therefore, it is cleaned whenever 'mvn clean' is run.
     */
    BrokerService brokerService = provider.getBroker();
    String path;
    URL url = this.getClass().getResource("/");

    /*
      Check if we are running it in within the jar, in which case we
      won't be able to use its location ...
     */

    if (url == null) {
        /*
         ... and, if that's the case, we use the OS temporary directory
         for the data directory
         */
        path = FileUtils.getTempDirectoryPath();
    }
    else {
        path = url.getPath();
    }

    brokerService.setDataDirectory(path);
    brokerService.setPersistent(false);

    try {
        logger.info("Adding MQTT connector");
        TransportConnector mqttConnector = new TransportConnector();

        mqttConnector.setUri(new URI("mqtt://localhost:1883"));
        mqttConnector.setName("mqtt");
        brokerService.addConnector(mqttConnector);


        logger.info("Adding AMQP connector");
        TransportConnector amqpConnector = new TransportConnector();
        amqpConnector.setUri(new URI("amqp://localhost:5672"));
        amqpConnector.setName("amqp");
        brokerService.addConnector(amqpConnector);

        TransportConnector defaultConnector = new TransportConnector();

        defaultConnector.setUri(new URI(CONNECTOR));
        defaultConnector.setName("default");
        brokerService.addConnector(defaultConnector);
    } catch (Exception e) {
        throw new RuntimeException("Unable to add a connector for the "
                + "service: " + e.getMessage(), e);
    }
}