use of org.apache.activemq.pool.PooledConnectionFactory in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testActiveMQOverriddenPool.
@Test
public void testActiveMQOverriddenPool() {
load(TestConfiguration.class, "spring.activemq.pool.enabled:true");
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
PooledConnectionFactory pool = this.context.getBean(PooledConnectionFactory.class);
assertThat(jmsTemplate).isNotNull();
assertThat(pool).isNotNull();
assertThat(pool).isEqualTo(jmsTemplate.getConnectionFactory());
ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory) pool.getConnectionFactory();
assertThat(factory.getBrokerURL()).isEqualTo(ACTIVEMQ_EMBEDDED_URL);
}
use of org.apache.activemq.pool.PooledConnectionFactory in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testActiveMQOverriddenPoolAndRemoteServer.
@Test
public void testActiveMQOverriddenPoolAndRemoteServer() {
load(TestConfiguration.class, "spring.activemq.pool.enabled:true", "spring.activemq.brokerUrl:tcp://remote-host:10000");
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
PooledConnectionFactory pool = this.context.getBean(PooledConnectionFactory.class);
assertThat(jmsTemplate).isNotNull();
assertThat(pool).isNotNull();
assertThat(pool).isEqualTo(jmsTemplate.getConnectionFactory());
ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory) pool.getConnectionFactory();
assertThat(factory.getBrokerURL()).isEqualTo("tcp://remote-host:10000");
}
use of org.apache.activemq.pool.PooledConnectionFactory in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testActiveMQOverriddenPoolAndStandalone.
@Test
public void testActiveMQOverriddenPoolAndStandalone() {
load(TestConfiguration.class, "spring.activemq.pool.enabled:true", "spring.activemq.inMemory:false");
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
PooledConnectionFactory pool = this.context.getBean(PooledConnectionFactory.class);
assertThat(jmsTemplate).isNotNull();
assertThat(pool).isNotNull();
assertThat(pool).isEqualTo(jmsTemplate.getConnectionFactory());
ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory) pool.getConnectionFactory();
assertThat(factory.getBrokerURL()).isEqualTo(ACTIVEMQ_NETWORK_URL);
}
use of org.apache.activemq.pool.PooledConnectionFactory in project spring-boot by spring-projects.
the class ActiveMQAutoConfigurationTests method customPooledConnectionFactoryConfiguration.
@Test
public void customPooledConnectionFactoryConfiguration() {
load(EmptyConfiguration.class, "spring.activemq.pool.enabled:true", "spring.activemq.pool.maxConnections:256", "spring.activemq.pool.idleTimeout:512", "spring.activemq.pool.expiryTimeout:4096", "spring.activemq.pool.configuration.maximumActiveSessionPerConnection:1024", "spring.activemq.pool.configuration.timeBetweenExpirationCheckMillis:2048");
ConnectionFactory connectionFactory = this.context.getBean(ConnectionFactory.class);
assertThat(connectionFactory).isInstanceOf(PooledConnectionFactory.class);
PooledConnectionFactory pooledConnectionFactory = (PooledConnectionFactory) connectionFactory;
assertThat(pooledConnectionFactory.getMaxConnections()).isEqualTo(256);
assertThat(pooledConnectionFactory.getIdleTimeout()).isEqualTo(512);
assertThat(pooledConnectionFactory.getMaximumActiveSessionPerConnection()).isEqualTo(1024);
assertThat(pooledConnectionFactory.getTimeBetweenExpirationCheckMillis()).isEqualTo(2048);
assertThat(pooledConnectionFactory.getExpiryTimeout()).isEqualTo(4096);
}
use of org.apache.activemq.pool.PooledConnectionFactory 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);
connectionFactory.setTrustAllPackages(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;
}
Aggregations