Search in sources :

Example 26 with PooledConnectionFactory

use of org.apache.activemq.pool.PooledConnectionFactory in project jim-framework by jiangmin168168.

the class ConnectionFactoryContainer method getPooledConnectionFactory.

public static PooledConnectionFactory getPooledConnectionFactory(String brokerUrl) {
    final String brokerClusterUrl = brokerUrl.replace(";", ",");
    PooledConnectionFactory connectionFactory = null;
    // ((ActiveMQConnectionFactory)connectionFactory.getConnectionFactory()).get;
    synchronized (lock) {
        if (producerConnectionFactoryMap.containsKey(brokerClusterUrl)) {
            connectionFactory = producerConnectionFactoryMap.get(brokerClusterUrl);
        } else {
            ProducerConnctionFactory producerConnctionFactory = new ProducerConnctionFactory();
            // producerConnctionFactory.init();
            connectionFactory = producerConnctionFactory.create(brokerClusterUrl);
            producerConnectionFactoryMap.put(brokerClusterUrl, connectionFactory);
        }
        return connectionFactory;
    }
}
Also used : PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) ProducerConnctionFactory(com.jim.framework.activemq.producer.ProducerConnctionFactory)

Example 27 with PooledConnectionFactory

use of org.apache.activemq.pool.PooledConnectionFactory in project jim-framework by jiangmin168168.

the class ConnectionFactoryContainer method getConsumerConnectionFactory.

public static PooledConnectionFactory getConsumerConnectionFactory(String brokerUrl) {
    PooledConnectionFactory connectionFactory = null;
    synchronized (lock) {
        if (consumerConnectionFactoryMap.containsKey(brokerUrl)) {
            connectionFactory = (PooledConnectionFactory) consumerConnectionFactoryMap.get(brokerUrl);
        } else {
            ConsumerConnctionFactory consumerConnctionFactory = new ConsumerConnctionFactory();
            // producerConnctionFactory.init();
            connectionFactory = consumerConnctionFactory.create(brokerUrl);
            consumerConnectionFactoryMap.put(brokerUrl, connectionFactory);
        }
        return connectionFactory;
    }
}
Also used : PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) ConsumerConnctionFactory(com.jim.framework.activemq.producer.ConsumerConnctionFactory)

Example 28 with PooledConnectionFactory

use of org.apache.activemq.pool.PooledConnectionFactory in project jim-framework by jiangmin168168.

the class ConnectionFactoryContainer method producerConnectionFactoryRebalance.

public static void producerConnectionFactoryRebalance() {
    for (Map.Entry<String, PooledConnectionFactory> entry : producerConnectionFactoryMap.entrySet()) {
        PooledConnectionFactory pooledConnectionFactory = entry.getValue();
        if (null != pooledConnectionFactory) {
            pooledConnectionFactory.setExpiryTimeout(30 * 1 * 1000);
            System.out.println("expirytimeount set to 60*2*1000");
        }
    }
}
Also used : PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map)

Example 29 with PooledConnectionFactory

use of org.apache.activemq.pool.PooledConnectionFactory in project jim-framework by jiangmin168168.

the class ConsumerConnctionFactory 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(1);
    connectionFactory.setCreateConnectionOnStartup(true);
    return connectionFactory;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory)

Aggregations

PooledConnectionFactory (org.apache.activemq.pool.PooledConnectionFactory)29 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)18 Test (org.junit.Test)5 Map (java.util.Map)4 JmsTemplate (org.springframework.jms.core.JmsTemplate)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ConnectionFactory (javax.jms.ConnectionFactory)3 ConnectionFactoryFeature (org.apache.cxf.transport.jms.ConnectionFactoryFeature)3 ProducerConnctionFactory (com.jim.framework.activemq.producer.ProducerConnctionFactory)2 File (java.io.File)2 RedeliveryPolicy (org.apache.activemq.RedeliveryPolicy)2 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)2 BeforeClass (org.junit.BeforeClass)2 ConsumerConnctionFactory (com.jim.framework.activemq.producer.ConsumerConnctionFactory)1 JimPooledConnectionFactory (com.jim.framework.activemq.producer.JimPooledConnectionFactory)1 List (java.util.List)1 PostConstruct (javax.annotation.PostConstruct)1 Connection (javax.jms.Connection)1 JMSException (javax.jms.JMSException)1 SOAPBinding (javax.xml.ws.soap.SOAPBinding)1