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);
}
};
}
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;
}
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;
}
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;
}
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;
}
Aggregations