use of org.apache.activemq.ActiveMQConnectionFactory in project camel by apache.
the class TransactedAsyncExceptionTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = super.createCamelContext();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(BROKER_URI);
connectionFactory.getRedeliveryPolicy().setInitialRedeliveryDelay(0);
connectionFactory.getRedeliveryPolicy().setRedeliveryDelay(0);
connectionFactory.getRedeliveryPolicy().setUseCollisionAvoidance(false);
connectionFactory.getRedeliveryPolicy().setUseExponentialBackOff(false);
connectionFactory.getRedeliveryPolicy().setMaximumRedeliveries(TRANSACTION_REDELIVERY_COUNT);
SjmsComponent component = new SjmsComponent();
component.setConnectionFactory(connectionFactory);
camelContext.addComponent("sjms", component);
return camelContext;
}
use of org.apache.activemq.ActiveMQConnectionFactory in project camel by apache.
the class SjmsEndpointNameOverrideTest method createCamelContext.
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = super.createCamelContext();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
SjmsComponent component = new SjmsComponent();
component.setConnectionCount(1);
component.setConnectionFactory(connectionFactory);
camelContext.addComponent(BEAN_NAME, component);
return camelContext;
}
use of org.apache.activemq.ActiveMQConnectionFactory in project camel by apache.
the class JmsEndpointConfigurationTest method createRegistry.
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry jndi = super.createRegistry();
jndi.bind("myConnectionFactory", new ActiveMQConnectionFactory("vm:myBroker"));
return jndi;
}
use of org.apache.activemq.ActiveMQConnectionFactory in project camel by apache.
the class CamelJmsTestHelper method createConnectionFactory.
public static ConnectionFactory createConnectionFactory(String options) {
// 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);
// use a pooled connection factory
PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
pooled.setMaxConnections(8);
return pooled;
}
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.setUseAsyncSend(true);
connectionFactory.setAlwaysSessionAsync(false);
// use a pooled connection factory
PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
pooled.setMaxConnections(8);
return pooled;
}
Aggregations