Search in sources :

Example 6 with BrokerService

use of org.apache.activemq.broker.BrokerService in project camel by apache.

the class PahoComponentTest method doPreSetup.

@Override
public void doPreSetup() throws Exception {
    super.doPreSetup();
    broker = new BrokerService();
    broker.setPersistent(false);
    broker.addConnector("mqtt://localhost:" + mqttPort);
    broker.start();
}
Also used : BrokerService(org.apache.activemq.broker.BrokerService)

Example 7 with BrokerService

use of org.apache.activemq.broker.BrokerService in project camel by apache.

the class JmsTestSupport method doPreSetup.

/** 
     * Set up the Broker
     *
     * @see org.apache.camel.test.junit4.CamelTestSupport#doPreSetup()
     *
     * @throws Exception
     */
@Override
protected void doPreSetup() throws Exception {
    deleteDirectory("target/activemq-data");
    broker = new BrokerService();
    int port = AvailablePortFinder.getNextAvailable(33333);
    brokerUri = "tcp://localhost:" + port;
    broker.getManagementContext().setConnectorPort(AvailablePortFinder.getNextAvailable(port + 1));
    configureBroker(broker);
    startBroker();
}
Also used : BrokerService(org.apache.activemq.broker.BrokerService)

Example 8 with BrokerService

use of org.apache.activemq.broker.BrokerService in project camel by apache.

the class SjmsConnectionTestSupport method createBroker.

protected void createBroker() throws Exception {
    String connectString = getConnectionUri();
    if (ObjectHelper.isEmpty(connectString)) {
        connectString = TCP_BROKER_CONNECT_STRING;
    }
    brokerService = new BrokerService();
    brokerService.setPersistent(isPersistenceEnabled());
    brokerService.addConnector(connectString);
    brokerService.start();
    brokerService.waitUntilStarted();
}
Also used : BrokerService(org.apache.activemq.broker.BrokerService)

Example 9 with BrokerService

use of org.apache.activemq.broker.BrokerService in project camel by apache.

the class MQTTDuplicatesTest method testMqttDuplicatesAfterBrokerRestartWithoutClientID.

@Test
public void testMqttDuplicatesAfterBrokerRestartWithoutClientID() throws Exception {
    brokerService.stop();
    brokerService.waitUntilStopped();
    LOG.info(">>>>>>>>>> Restarting broker...");
    brokerService = new BrokerService();
    brokerService.setPersistent(false);
    brokerService.setAdvisorySupport(false);
    brokerService.addConnector(MQTTTestSupport.getConnection() + "?trace=true");
    brokerService.start();
    brokerService.waitUntilStarted();
    LOG.info(">>>>>>>>>> Broker restarted");
    for (int i = 0; i < MESSAGE_COUNT; i++) {
        String body = System.currentTimeMillis() + ": Dummy-restart-without-clientID! " + i;
        templateWithoutClientID.asyncSendBody("direct:withoutClientID", body);
        Thread.sleep(WAIT_MILLIS);
    }
    assertNoDuplicates();
}
Also used : BrokerService(org.apache.activemq.broker.BrokerService) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 10 with BrokerService

use of org.apache.activemq.broker.BrokerService in project beam by apache.

the class JmsIOTest method startBroker.

@Before
public void startBroker() throws Exception {
    broker = new BrokerService();
    broker.setUseJmx(false);
    broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
    broker.addConnector(BROKER_URL);
    broker.setBrokerName("localhost");
    broker.setPopulateJMSXUserID(true);
    broker.setUseAuthenticatedPrincipalForJMSXUserID(true);
    // enable authentication
    List<AuthenticationUser> users = new ArrayList<>();
    // username and password to use to connect to the broker.
    // This user has users privilege (able to browse, consume, produce, list destinations)
    users.add(new AuthenticationUser(USERNAME, PASSWORD, "users"));
    SimpleAuthenticationPlugin plugin = new SimpleAuthenticationPlugin(users);
    BrokerPlugin[] plugins = new BrokerPlugin[] { plugin };
    broker.setPlugins(plugins);
    broker.start();
    // create JMS connection factory
    connectionFactory = new ActiveMQConnectionFactory(BROKER_URL);
    connectionFactoryWithoutPrefetch = new ActiveMQConnectionFactory(BROKER_URL + "?jms.prefetchPolicy.all=0");
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) MemoryPersistenceAdapter(org.apache.activemq.store.memory.MemoryPersistenceAdapter) SimpleAuthenticationPlugin(org.apache.activemq.security.SimpleAuthenticationPlugin) ArrayList(java.util.ArrayList) BrokerPlugin(org.apache.activemq.broker.BrokerPlugin) BrokerService(org.apache.activemq.broker.BrokerService) AuthenticationUser(org.apache.activemq.security.AuthenticationUser) Before(org.junit.Before)

Aggregations

BrokerService (org.apache.activemq.broker.BrokerService)40 Test (org.junit.Test)13 URI (java.net.URI)10 ServletContext (javax.servlet.ServletContext)7 ServletContextEvent (javax.servlet.ServletContextEvent)7 MemoryPersistenceAdapter (org.apache.activemq.store.memory.MemoryPersistenceAdapter)5 Before (org.junit.Before)5 PersistenceAdapter (org.apache.activemq.store.PersistenceAdapter)4 JDBCPersistenceAdapter (org.apache.activemq.store.jdbc.JDBCPersistenceAdapter)4 Properties (java.util.Properties)3 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)3 ServerSocket (java.net.ServerSocket)2 HashMap (java.util.HashMap)2 BrokerPlugin (org.apache.activemq.broker.BrokerPlugin)2 PolicyEntry (org.apache.activemq.broker.region.policy.PolicyEntry)2 PolicyMap (org.apache.activemq.broker.region.policy.PolicyMap)2 SystemUsage (org.apache.activemq.usage.SystemUsage)2 URISupport (org.apache.activemq.util.URISupport)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 JDBCDataSource (org.hsqldb.jdbc.JDBCDataSource)2