Search in sources :

Example 1 with PooledConnectionFactory

use of org.apache.activemq.jms.pool.PooledConnectionFactory in project kylo by Teradata.

the class ActivemqPoolableConnectionProvider method activemqPoolableConnection.

/**
 * @param activemqBrokerUrl  - Activemq Broker Connection String
 * @return pooled connection
 */
public PooledConnectionFactory activemqPoolableConnection(String activemqBrokerUrl) {
    /**
     * Initialise Activemq Factory for Connection
     */
    ActiveMQConnectionFactory factory = initializeActiveMqFactoryConnection(activemqBrokerUrl);
    /**
     * Create Connection Pool using PooledConnectionFactory and add connectionFactory to it.
     */
    PooledConnectionFactory poolConnection = new PooledConnectionFactory();
    poolConnection.setConnectionFactory(factory);
    /**
     * Return connection from Pool
     */
    return poolConnection;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) PooledConnectionFactory(org.apache.activemq.jms.pool.PooledConnectionFactory)

Example 2 with PooledConnectionFactory

use of org.apache.activemq.jms.pool.PooledConnectionFactory in project tesb-rt-se by Talend.

the class ImporterTest method createJmsComponent.

private JmsComponent createJmsComponent() {
    JmsComponent jmsComponent = new JmsComponent();
    PooledConnectionFactory pooled = createConnectionFactory();
    jmsComponent.setConnectionFactory(pooled);
    return jmsComponent;
}
Also used : JmsComponent(org.apache.camel.component.jms.JmsComponent) PooledConnectionFactory(org.apache.activemq.jms.pool.PooledConnectionFactory)

Example 3 with PooledConnectionFactory

use of org.apache.activemq.jms.pool.PooledConnectionFactory in project elephant by yanghuijava.

the class ActivemqConfig method singleConnectionFactory.

@Bean
@ConditionalOnProperty(prefix = "elephant.mq", value = "activemq-broker-url")
public SingleConnectionFactory singleConnectionFactory() {
    ActiveMQConnectionFactory targetConnectionFactory = new ActiveMQConnectionFactory(this.mqProperties.getActivemqBrokerUrl());
    if (!StringUtils.isEmpty(this.mqProperties.getActivemqUserName()) && !StringUtils.isEmpty(this.mqProperties.getActivemqPassword())) {
        targetConnectionFactory.setUserName(this.mqProperties.getActivemqUserName());
        targetConnectionFactory.setPassword(this.mqProperties.getActivemqPassword());
    } else {
        targetConnectionFactory.setUserName(ActiveMQConnectionFactory.DEFAULT_USER);
        targetConnectionFactory.setPassword(ActiveMQConnectionFactory.DEFAULT_PASSWORD);
    }
    PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory();
    pooledConnectionFactory.setConnectionFactory(targetConnectionFactory);
    pooledConnectionFactory.setMaxConnections(this.mqProperties.getActivemqPoolMaxConnections());
    SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory();
    singleConnectionFactory.setTargetConnectionFactory(pooledConnectionFactory);
    return singleConnectionFactory;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) SingleConnectionFactory(org.springframework.jms.connection.SingleConnectionFactory) PooledConnectionFactory(org.apache.activemq.jms.pool.PooledConnectionFactory) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)

Example 4 with PooledConnectionFactory

use of org.apache.activemq.jms.pool.PooledConnectionFactory in project elephant by yanghuijava.

the class ActivemqConfig method singleConnectionFactory.

@Bean
public SingleConnectionFactory singleConnectionFactory(RedeliveryPolicy redeliveryPolicy) {
    ActiveMQConnectionFactory targetConnectionFactory = new ActiveMQConnectionFactory(this.mqProperties.getActivemqBrokerUrl());
    if (!StringUtils.isEmpty(this.mqProperties.getActivemqUserName()) && !StringUtils.isEmpty(this.mqProperties.getActivemqPassword())) {
        targetConnectionFactory.setUserName(this.mqProperties.getActivemqUserName());
        targetConnectionFactory.setPassword(this.mqProperties.getActivemqPassword());
    } else {
        targetConnectionFactory.setUserName(ActiveMQConnectionFactory.DEFAULT_USER);
        targetConnectionFactory.setPassword(ActiveMQConnectionFactory.DEFAULT_PASSWORD);
    }
    targetConnectionFactory.setRedeliveryPolicy(redeliveryPolicy);
    PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory();
    pooledConnectionFactory.setConnectionFactory(targetConnectionFactory);
    pooledConnectionFactory.setMaxConnections(this.mqProperties.getActivemqPoolMaxConnections());
    SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory();
    singleConnectionFactory.setTargetConnectionFactory(pooledConnectionFactory);
    return singleConnectionFactory;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) SingleConnectionFactory(org.springframework.jms.connection.SingleConnectionFactory) PooledConnectionFactory(org.apache.activemq.jms.pool.PooledConnectionFactory) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) Bean(org.springframework.context.annotation.Bean)

Example 5 with PooledConnectionFactory

use of org.apache.activemq.jms.pool.PooledConnectionFactory in project tesb-rt-se by Talend.

the class ImporterTest method createConnectionFactory.

private PooledConnectionFactory createConnectionFactory() {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("localhost:61616");
    RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
    redeliveryPolicy.setMaximumRedeliveries(2);
    connectionFactory.setRedeliveryPolicy(redeliveryPolicy);
    PooledConnectionFactory pooled = new PooledConnectionFactory();
    pooled.setConnectionFactory(connectionFactory);
    return pooled;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) RedeliveryPolicy(org.apache.activemq.RedeliveryPolicy) PooledConnectionFactory(org.apache.activemq.jms.pool.PooledConnectionFactory)

Aggregations

PooledConnectionFactory (org.apache.activemq.jms.pool.PooledConnectionFactory)5 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)4 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)2 Bean (org.springframework.context.annotation.Bean)2 SingleConnectionFactory (org.springframework.jms.connection.SingleConnectionFactory)2 RedeliveryPolicy (org.apache.activemq.RedeliveryPolicy)1 JmsComponent (org.apache.camel.component.jms.JmsComponent)1 ConditionalOnProperty (org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)1