Search in sources :

Example 86 with BrokerService

use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.

the class DiscoveryUriTest method createBroker.

@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;
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) BrokerService(org.apache.activemq.broker.BrokerService) URI(java.net.URI)

Example 87 with BrokerService

use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.

the class FailoverClusterTestSupport method createBroker.

protected BrokerService createBroker(String brokerName) throws Exception {
    BrokerService answer = new BrokerService();
    answer.setPersistent(false);
    answer.setUseJmx(false);
    answer.setBrokerName(brokerName);
    answer.setUseShutdownHook(false);
    return answer;
}
Also used : BrokerService(org.apache.activemq.broker.BrokerService)

Example 88 with BrokerService

use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.

the class DiscoveryTransportNoBrokerTest method testNoExtraThreads.

public void testNoExtraThreads() throws Exception {
    BrokerService broker = new BrokerService();
    TransportConnector tcp = broker.addConnector("tcp://localhost:0?transport.closeAsync=false");
    String group = "GR-" + System.currentTimeMillis();
    URI discoveryUri = new URI("multicast://default?group=" + group);
    tcp.setDiscoveryUri(discoveryUri);
    broker.start();
    broker.waitUntilStarted();
    Vector<String> existingNames = new Vector<>();
    Thread[] threads = getThreads();
    for (Thread t : threads) {
        existingNames.add(t.getName());
    }
    final int idleThreadCount = threads.length;
    LOG.info("Broker started - thread Count:" + idleThreadCount);
    final int noConnectionToCreate = 10;
    for (int i = 0; i < 10; i++) {
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("discovery:(multicast://239.255.2.3:6155?group=" + group + ")?closeAsync=false&startupMaxReconnectAttempts=10&initialReconnectDelay=1000");
        LOG.info("Connecting.");
        Connection connection = factory.createConnection();
        connection.setClientID("test");
        connection.close();
    }
    Thread.sleep(2000);
    threads = getThreads();
    for (Thread t : threads) {
        if (!existingNames.contains(t.getName())) {
            LOG.info("Remaining thread:" + t);
        }
    }
    assertTrue("no extra threads per connection", Thread.activeCount() - idleThreadCount < noConnectionToCreate);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) TransportConnector(org.apache.activemq.broker.TransportConnector) Connection(javax.jms.Connection) BrokerService(org.apache.activemq.broker.BrokerService) URI(java.net.URI) Vector(java.util.Vector)

Example 89 with BrokerService

use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.

the class NIOJmsDurableTopicSendReceiveTest method createBroker.

protected BrokerService createBroker() throws Exception {
    BrokerService answer = new BrokerService();
    answer.setPersistent(false);
    answer.addConnector(getBrokerURL());
    return answer;
}
Also used : BrokerService(org.apache.activemq.broker.BrokerService)

Example 90 with BrokerService

use of org.apache.activemq.broker.BrokerService in project activemq-artemis by apache.

the class NIOPersistentSendAndReceiveTest method createBroker.

@Override
protected BrokerService createBroker() throws Exception {
    BrokerService answer = new BrokerService();
    answer.setPersistent(true);
    answer.addConnector(getBrokerURL());
    return answer;
}
Also used : BrokerService(org.apache.activemq.broker.BrokerService)

Aggregations

BrokerService (org.apache.activemq.broker.BrokerService)349 URI (java.net.URI)53 PolicyEntry (org.apache.activemq.broker.region.policy.PolicyEntry)45 PolicyMap (org.apache.activemq.broker.region.policy.PolicyMap)45 Test (org.junit.Test)43 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)32 TransportConnector (org.apache.activemq.broker.TransportConnector)31 Before (org.junit.Before)22 File (java.io.File)20 MemoryPersistenceAdapter (org.apache.activemq.store.memory.MemoryPersistenceAdapter)17 JMSException (javax.jms.JMSException)16 JDBCPersistenceAdapter (org.apache.activemq.store.jdbc.JDBCPersistenceAdapter)14 KahaDBPersistenceAdapter (org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter)14 BrokerFactoryBean (org.apache.activemq.xbean.BrokerFactoryBean)14 NetworkConnector (org.apache.activemq.network.NetworkConnector)13 MessageConsumer (javax.jms.MessageConsumer)12 PersistenceAdapter (org.apache.activemq.store.PersistenceAdapter)12 ArrayList (java.util.ArrayList)11 Destination (javax.jms.Destination)11 ClassPathResource (org.springframework.core.io.ClassPathResource)10