Search in sources :

Example 6 with PooledConnectionFactory

use of org.apache.activemq.pool.PooledConnectionFactory in project camel by apache.

the class CamelJmsTestHelper method createPooledConnectionFactory.

public static PooledConnectionFactory createPooledConnectionFactory() {
    ConnectionFactory cf = createConnectionFactory(null, null);
    PooledConnectionFactory pooled = new PooledConnectionFactory();
    pooled.setConnectionFactory(cf);
    pooled.setMaxConnections(8);
    return pooled;
}
Also used : PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) ConnectionFactory(javax.jms.ConnectionFactory) ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory)

Example 7 with PooledConnectionFactory

use of org.apache.activemq.pool.PooledConnectionFactory in project ddf by codice.

the class OpenwireProducerConsumerExample method createCamelContext.

private void createCamelContext() throws Exception {
    CamelContext camelContext = getContext();
    ConnectionFactory jmsConnectFactory = createConnectionFactory();
    PooledConnectionFactory jmsPooledConnectionFactory = new PooledConnectionFactory();
    jmsPooledConnectionFactory.setConnectionFactory(jmsConnectFactory);
    jmsPooledConnectionFactory.setMaxConnections(2);
    JmsTransactionManager jmsTransactionManager = new JmsTransactionManager();
    jmsTransactionManager.setConnectionFactory(jmsConnectFactory);
    JmsConfiguration jmsConfiguration = new JmsConfiguration();
    jmsConfiguration.setConnectionFactory(jmsPooledConnectionFactory);
    jmsConfiguration.setTransacted(true);
    jmsConfiguration.setTransactionManager(jmsTransactionManager);
    jmsConfiguration.setCacheLevelName("CACHE_CONSUMER");
    JmsComponent jms = new JmsComponent();
    jms.setConfiguration(jmsConfiguration);
    camelContext.addComponent("jms", jms);
}
Also used : CamelContext(org.apache.camel.CamelContext) ActiveMQSslConnectionFactory(org.apache.activemq.ActiveMQSslConnectionFactory) ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) ConnectionFactory(javax.jms.ConnectionFactory) JmsComponent(org.apache.camel.component.jms.JmsComponent) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) JmsConfiguration(org.apache.camel.component.jms.JmsConfiguration) JmsTransactionManager(org.springframework.jms.connection.JmsTransactionManager)

Example 8 with PooledConnectionFactory

use of org.apache.activemq.pool.PooledConnectionFactory in project cxf by apache.

the class MultiTransportClientServerTest method startServers.

@BeforeClass
public static void startServers() throws Exception {
    bus = BusFactory.getDefaultBus();
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
    PooledConnectionFactory cfp = new PooledConnectionFactory(cf);
    cff = new ConnectionFactoryFeature(cfp);
    String address = "http://localhost:" + PORT + "/SOAPDocLitService/SoapPort";
    Endpoint.publish(address, new HTTPGreeterImpl());
    EndpointImpl ep1 = (EndpointImpl) Endpoint.create(new JMSGreeterImpl());
    ep1.setBus(bus);
    ep1.getFeatures().add(cff);
    ep1.publish();
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) HTTPGreeterImpl(org.apache.hello_world_doc_lit.HTTPGreeterImpl) ConnectionFactoryFeature(org.apache.cxf.transport.jms.ConnectionFactoryFeature) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) JMSGreeterImpl(org.apache.hello_world_doc_lit.JMSGreeterImpl) BeforeClass(org.junit.BeforeClass)

Example 9 with PooledConnectionFactory

use of org.apache.activemq.pool.PooledConnectionFactory in project cxf by apache.

the class AbstractVmJMSTest method startBusAndJMS.

public static void startBusAndJMS(String brokerURI) {
    bus = BusFactory.getDefaultBus();
    ActiveMQConnectionFactory cf1 = new ActiveMQConnectionFactory(brokerURI);
    RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
    redeliveryPolicy.setMaximumRedeliveries(1);
    redeliveryPolicy.setInitialRedeliveryDelay(1000);
    cf1.setRedeliveryPolicy(redeliveryPolicy());
    cf = new PooledConnectionFactory(cf1);
    cff = new ConnectionFactoryFeature(cf);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) ConnectionFactoryFeature(org.apache.cxf.transport.jms.ConnectionFactoryFeature) RedeliveryPolicy(org.apache.activemq.RedeliveryPolicy) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory)

Example 10 with PooledConnectionFactory

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

the class ProductController method test.

@RequestMapping("/test/{productId}")
public Long test(@PathVariable final long productId) {
    productProducer.sendMessage(productId);
    Map<String, PooledConnectionFactory> pooledConnectionFactoryMap = ConnectionFactoryContainer.getAllPooledConnectionFactory();
    for (Map.Entry<String, PooledConnectionFactory> entry : pooledConnectionFactoryMap.entrySet()) {
        JimPooledConnectionFactory jimPooledConnectionFactory = (JimPooledConnectionFactory) entry.getValue();
        // jimPooledConnectionFactory.setExpiryTimeout();
        GenericKeyedObjectPool<ConnectionKey, ConnectionPool> jimConnectionsPool = ((JimPooledConnectionFactory) entry.getValue()).getJimConnectionsPool();
        // jimConnectionsPool.
        jimConnectionsPool.clearOldest();
        // jimConnectionsPool.set
        Map<String, List<DefaultPooledObjectInfo>> defStringListMap = jimConnectionsPool.listAllObjects();
        for (Map.Entry<String, List<DefaultPooledObjectInfo>> entry1 : defStringListMap.entrySet()) {
            List<DefaultPooledObjectInfo> defaultPooledObjectInfos = entry1.getValue();
            System.out.println("123");
            for (DefaultPooledObjectInfo defaultPooledObjectInfo : defaultPooledObjectInfos) {
                // defaultPooledObjectInfo.
                System.out.println("123");
            // ((ConnectionPool)defaultPooledObjectInfo.pooledObject.getObject()).connection;
            }
        }
        // jimConnectionsPool.get
        System.out.println("123");
    // ((ObjectDeque)((java.util.concurrent.ConcurrentHashMap.MapEntry)((java.util.concurrent.ConcurrentHashMap)jimConnectionsPool.poolMap).entrySet().toArray()[0]).getValue()).allObjects
    }
    return productId;
}
Also used : ConnectionPool(org.apache.activemq.jms.pool.ConnectionPool) DefaultPooledObjectInfo(org.apache.commons.pool2.impl.DefaultPooledObjectInfo) ConnectionKey(org.apache.activemq.jms.pool.ConnectionKey) JimPooledConnectionFactory(com.jim.framework.activemq.producer.JimPooledConnectionFactory) JimPooledConnectionFactory(com.jim.framework.activemq.producer.JimPooledConnectionFactory) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) List(java.util.List) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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