Java Code Examples for org.apache.activemq.broker.TransportConnector#setUri()
The following examples show how to use
org.apache.activemq.broker.TransportConnector#setUri() .
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: JMSBroker.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * 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 2
Source File: JMSEndpointSuspensionViaVFSTest.java From micro-integrator with Apache License 2.0 | 5 votes |
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 3
Source File: JMSBroker.java From product-ei with Apache License 2.0 | 5 votes |
/** * 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 product-ei with Apache License 2.0 | 5 votes |
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: EndpointConfig.java From camelinaction2 with Apache License 2.0 | 5 votes |
/** * ActiveMQ message broker as embedded service. */ @Bean public BrokerService jmsMessageBroker() throws Exception { XBeanBrokerService messageBroker = new XBeanBrokerService (); TransportConnector connector = new TransportConnector(); connector.setUri(new URI(jmsBrokerUrl)); messageBroker.addConnector(connector); messageBroker.setStart(true); messageBroker.setUseJmx(false); messageBroker.setPersistent(false); return messageBroker; }
Example 6
Source File: FailoverStaticNetworkTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
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; }
Example 7
Source File: FailoverStaticNetworkTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private BrokerService createBroker(String listenPort, String dataDir) throws Exception { BrokerService broker = new BrokerService(); broker.setUseJmx(false); broker.getManagementContext().setCreateConnector(false); broker.setBrokerName("Broker_Shared"); // lazy create transport connector on start completion TransportConnector connector = new TransportConnector(); connector.setUri(new URI("tcp://localhost:" + listenPort)); broker.addConnector(connector); broker.setDataDirectory(dataDir); return broker; }
Example 8
Source File: mKahaDbQueueMasterSlaveTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void createSlave() throws Exception { // use a separate thread as the slave will block waiting for // the exclusive db lock Thread t = new Thread() { @Override public void run() { try { BrokerService broker = new BrokerService(); broker.setBrokerName("slave"); TransportConnector connector = new TransportConnector(); connector.setUri(new URI(SLAVE_URL)); broker.addConnector(connector); // no need for broker.setMasterConnectorURI(masterConnectorURI) // as the db lock provides the slave/master initialisation broker.setUseJmx(false); broker.setPersistent(true); MultiKahaDBPersistenceAdapter mKahaDB = new MultiKahaDBPersistenceAdapter(); List<FilteredKahaDBPersistenceAdapter> adapters = new LinkedList<>(); FilteredKahaDBPersistenceAdapter defaultEntry = new FilteredKahaDBPersistenceAdapter(); defaultEntry.setPersistenceAdapter(new KahaDBPersistenceAdapter()); defaultEntry.setPerDestination(true); adapters.add(defaultEntry); mKahaDB.setFilteredPersistenceAdapters(adapters); broker.setPersistenceAdapter(mKahaDB); broker.start(); slave.set(broker); slaveStarted.countDown(); } catch (IllegalStateException expectedOnShutdown) { } catch (Exception e) { fail("failed to start slave broker, reason:" + e); } } }; t.start(); }
Example 9
Source File: kahaDbJdbcLeaseQueueMasterSlaveTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void createSlave() throws Exception { // use a separate thread as the slave will block waiting for // the exclusive db lock Thread t = new Thread() { @Override public void run() { try { BrokerService broker = new BrokerService(); broker.setBrokerName("slave"); TransportConnector connector = new TransportConnector(); connector.setUri(new URI(SLAVE_URL)); broker.addConnector(connector); broker.setUseJmx(false); broker.setPersistent(true); KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter(); LeaseDatabaseLocker leaseDatabaseLocker = new LeaseDatabaseLocker(); leaseDatabaseLocker.setDataSource(getExistingDataSource()); leaseDatabaseLocker.setStatements(new Statements()); kahaDBPersistenceAdapter.setLocker(leaseDatabaseLocker); configureLocker(kahaDBPersistenceAdapter); configureBroker(broker); broker.start(); slave.set(broker); slaveStarted.countDown(); } catch (IllegalStateException expectedOnShutdown) { } catch (Exception e) { fail("failed to start slave broker, reason:" + e); } } }; t.start(); }
Example 10
Source File: JDBCQueueMasterSlaveTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override protected void createSlave() throws Exception { // use a separate thread as the slave will block waiting for // the exclusive db lock Thread t = new Thread() { @Override public void run() { try { BrokerService broker = new BrokerService(); broker.setBrokerName("slave"); TransportConnector connector = new TransportConnector(); connector.setUri(new URI(SLAVE_URL)); broker.addConnector(connector); // no need for broker.setMasterConnectorURI(masterConnectorURI) // as the db lock provides the slave/master initialisation broker.setUseJmx(false); broker.setPersistent(true); JDBCPersistenceAdapter persistenceAdapter = new JDBCPersistenceAdapter(); persistenceAdapter.setDataSource(getExistingDataSource()); persistenceAdapter.setCreateTablesOnStartup(false); broker.setPersistenceAdapter(persistenceAdapter); configureJdbcPersistenceAdapter(persistenceAdapter); configureBroker(broker); broker.start(); slave.set(broker); slaveStarted.countDown(); } catch (IllegalStateException expectedOnShutdown) { } catch (Exception e) { fail("failed to start slave broker, reason:" + e); } } }; t.start(); }
Example 11
Source File: DiscoveryUriTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@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 12
Source File: AMQStackOverFlowTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
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 13
Source File: AbstractElasticSearchActiveMQTest.java From camunda-bpm-elasticsearch with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { broker = createBroker(); connector = new TransportConnector(); connector.setUri(new URI("vm://localhost")); broker.addConnector(connector); broker.start(); ActiveMQConnectionFactory connFactory = new ActiveMQConnectionFactory(connector.getConnectUri() + "?jms.prefetchPolicy.all=1"); connection = connFactory.createConnection(); connection.start(); }
Example 14
Source File: MiniBrokerConfiguration.java From maestro-java with Apache License 2.0 | 4 votes |
/** * 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); } }
Example 15
Source File: NetworkLoadTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
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; }