Search in sources :

Example 1 with ProducerConnctionFactory

use of com.jim.framework.activemq.producer.ProducerConnctionFactory 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;
    }
}
Also used : PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) ProducerConnctionFactory(com.jim.framework.activemq.producer.ProducerConnctionFactory)

Example 2 with ProducerConnctionFactory

use of com.jim.framework.activemq.producer.ProducerConnctionFactory 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)

Aggregations

ProducerConnctionFactory (com.jim.framework.activemq.producer.ProducerConnctionFactory)2 PooledConnectionFactory (org.apache.activemq.pool.PooledConnectionFactory)2