Search in sources :

Example 56 with ActiveMQConnectionFactory

use of org.apache.activemq.ActiveMQConnectionFactory in project camel by apache.

the class SimpleJmsComponentTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        public void configure() {
            ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
            SjmsComponent component = new SjmsComponent();
            component.setConnectionFactory(connectionFactory);
            getContext().addComponent("sjms", component);
        }
    };
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) RouteBuilder(org.apache.camel.builder.RouteBuilder)

Example 57 with ActiveMQConnectionFactory

use of org.apache.activemq.ActiveMQConnectionFactory in project camel by apache.

the class SjmsComponentRestartTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
    JndiRegistry jndi = super.createRegistry();
    jndi.bind("activemqCF", connectionFactory);
    return jndi;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) JndiRegistry(org.apache.camel.impl.JndiRegistry)

Example 58 with ActiveMQConnectionFactory

use of org.apache.activemq.ActiveMQConnectionFactory in project camel by apache.

the class CamelJmsTestHelper method createPersistentConnectionFactory.

public static ConnectionFactory createPersistentConnectionFactory(String options) {
    // using a unique broker name improves testing when running the entire test suite in the same JVM
    int id = counter.incrementAndGet();
    // use an unique data directory in target
    String dir = "target/activemq-data-" + id;
    // remove dir so its empty on startup
    FileUtil.removeDir(new File(dir));
    String url = "vm://test-broker-" + id + "?broker.persistent=true&broker.useJmx=false&broker.dataDirectory=" + dir;
    if (options != null) {
        url = url + "&" + options;
    }
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
    // optimize AMQ to be as fast as possible so unit testing is quicker
    connectionFactory.setCopyMessageOnSend(false);
    connectionFactory.setOptimizeAcknowledge(true);
    connectionFactory.setOptimizedMessageDispatch(true);
    connectionFactory.setAlwaysSessionAsync(false);
    connectionFactory.setTrustAllPackages(true);
    return connectionFactory;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) File(java.io.File)

Example 59 with ActiveMQConnectionFactory

use of org.apache.activemq.ActiveMQConnectionFactory in project camel by apache.

the class CamelJmsTestHelper method createConnectionFactory.

public static ConnectionFactory createConnectionFactory(String options, Integer maximumRedeliveries) {
    // using a unique broker name improves testing when running the entire test suite in the same JVM
    int id = counter.incrementAndGet();
    String url = "vm://test-broker-" + id + "?broker.persistent=false&broker.useJmx=false";
    if (options != null) {
        url = url + "&" + options;
    }
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
    // optimize AMQ to be as fast as possible so unit testing is quicker
    connectionFactory.setCopyMessageOnSend(false);
    connectionFactory.setOptimizeAcknowledge(true);
    connectionFactory.setOptimizedMessageDispatch(true);
    // When using asyncSend, producers will not be guaranteed to send in the order we
    // have in the tests (which may be confusing for queues) so we need this set to false.
    // Another way of guaranteeing order is to use persistent messages or transactions.
    connectionFactory.setUseAsyncSend(false);
    connectionFactory.setAlwaysSessionAsync(false);
    if (maximumRedeliveries != null) {
        connectionFactory.getRedeliveryPolicy().setMaximumRedeliveries(maximumRedeliveries);
    }
    connectionFactory.setTrustAllPackages(true);
    return connectionFactory;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory)

Example 60 with ActiveMQConnectionFactory

use of org.apache.activemq.ActiveMQConnectionFactory in project camel by apache.

the class InOnlyTopicDurableConsumerTest method createCamelContext.

/*
     * @see org.apache.camel.test.junit4.CamelTestSupport#createCamelContext()
     *
     * @return
     * @throws Exception
     */
@Override
protected CamelContext createCamelContext() throws Exception {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(BROKER_URI);
    ConnectionFactoryResource connectionResource = new ConnectionFactoryResource();
    connectionResource.setConnectionFactory(connectionFactory);
    connectionResource.setClientId(CONNECTION_ID);
    CamelContext camelContext = super.createCamelContext();
    Sjms2Component component = new Sjms2Component();
    component.setConnectionResource(connectionResource);
    component.setConnectionCount(1);
    camelContext.addComponent("sjms2", component);
    return camelContext;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) CamelContext(org.apache.camel.CamelContext) ConnectionFactoryResource(org.apache.camel.component.sjms.jms.ConnectionFactoryResource) Sjms2Component(org.apache.camel.component.sjms2.Sjms2Component)

Aggregations

ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)69 CamelContext (org.apache.camel.CamelContext)25 SjmsComponent (org.apache.camel.component.sjms.SjmsComponent)16 ConnectionFactory (javax.jms.ConnectionFactory)11 Test (org.junit.Test)10 PooledConnectionFactory (org.apache.activemq.pool.PooledConnectionFactory)9 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)8 JmsTemplate (org.springframework.jms.core.JmsTemplate)7 Connection (javax.jms.Connection)6 Session (javax.jms.Session)6 Before (org.junit.Before)5 MessageProducer (javax.jms.MessageProducer)4 RouteBuilder (org.apache.camel.builder.RouteBuilder)4 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)4 File (java.io.File)3 Destination (javax.jms.Destination)3 JMSException (javax.jms.JMSException)3 MessageConsumer (javax.jms.MessageConsumer)3 BrokerService (org.apache.activemq.broker.BrokerService)3 ArrayList (java.util.ArrayList)2