use of org.apache.activemq.pool.PooledConnectionFactory in project jim-framework by jiangmin168168.
the class ProducerConnctionFactory method create.
public PooledConnectionFactory create(String brokerClusterUrl) {
ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory();
mqConnectionFactory.setBrokerURL(brokerClusterUrl);
mqConnectionFactory.setTransportListener(this);
// mqConnectionFactory.
PooledConnectionFactory connectionFactory = new JimPooledConnectionFactory(mqConnectionFactory);
connectionFactory.setMaxConnections(10);
connectionFactory.setTimeBetweenExpirationCheckMillis(1000);
return connectionFactory;
}
use of org.apache.activemq.pool.PooledConnectionFactory in project jim-framework by jiangmin168168.
the class ConnectionFactoryContainer method stopProducerConnectionFactory.
public static void stopProducerConnectionFactory() {
for (Map.Entry<String, PooledConnectionFactory> entry : producerConnectionFactoryMap.entrySet()) {
PooledConnectionFactory pooledConnectionFactory = entry.getValue();
if (null != pooledConnectionFactory) {
// pooledConnectionFactory.stop();
needToRemoveConnctionFactories.add(pooledConnectionFactory);
producerConnectionFactoryMap.remove(entry.getKey());
}
}
}
use of org.apache.activemq.pool.PooledConnectionFactory in project jim-framework by jiangmin168168.
the class ConnectionFactoryContainer method createPooledConnectionFactory.
public static PooledConnectionFactory createPooledConnectionFactory(String brokerUrl) {
final String brokerClusterUrl = brokerUrl.replace(";", ",");
PooledConnectionFactory connectionFactory = null;
// ((ActiveMQConnectionFactory)connectionFactory.getConnectionFactory()).get;
synchronized (lock) {
if (producerConnectionFactoryMap.containsKey(brokerClusterUrl)) {
connectionFactory = producerConnectionFactoryMap.get(brokerClusterUrl);
needToRemoveConnctionFactories.add(connectionFactory);
producerConnectionFactoryMap.remove(brokerUrl);
}
ProducerConnctionFactory producerConnctionFactory = new ProducerConnctionFactory();
// producerConnctionFactory.init();
connectionFactory = producerConnctionFactory.create(brokerClusterUrl);
producerConnectionFactoryMap.put(brokerClusterUrl, connectionFactory);
return connectionFactory;
}
}
use of org.apache.activemq.pool.PooledConnectionFactory in project oxAuth by GluuFederation.
the class ApplicationAuditLogger method tryToEstablishJMSConnectionImpl.
private boolean tryToEstablishJMSConnectionImpl() {
Set<String> jmsBrokerURISet = appConfiguration.getJmsBrokerURISet();
if (!enabled || CollectionUtils.isEmpty(jmsBrokerURISet)) {
return false;
}
this.jmsBrokerURISet = new HashSet<String>(jmsBrokerURISet);
this.jmsUserName = appConfiguration.getJmsUserName();
this.jmsPassword = appConfiguration.getJmsPassword();
Iterator<String> jmsBrokerURIIterator = jmsBrokerURISet.iterator();
StringBuilder uriBuilder = new StringBuilder();
while (jmsBrokerURIIterator.hasNext()) {
String jmsBrokerURI = jmsBrokerURIIterator.next();
uriBuilder.append("tcp://");
uriBuilder.append(jmsBrokerURI);
if (jmsBrokerURIIterator.hasNext()) {
uriBuilder.append(",");
}
}
String brokerUrl = BROKER_URL_PREFIX + uriBuilder + BROKER_URL_SUFFIX;
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(this.jmsUserName, this.jmsPassword, brokerUrl);
this.pooledConnectionFactory = new PooledConnectionFactory(connectionFactory);
pooledConnectionFactory.setIdleTimeout(5000);
pooledConnectionFactory.setMaxConnections(10);
pooledConnectionFactory.start();
return true;
}
use of org.apache.activemq.pool.PooledConnectionFactory 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);
connectionFactory.setTrustAllPackages(true);
// use a pooled connection factory
PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
pooled.setMaxConnections(8);
return pooled;
}
Aggregations