Search in sources :

Example 21 with PooledConnectionFactory

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

the class ClientMtomXopWithJMSTest method startServers.

@BeforeClass
public static void startServers() throws Exception {
    Object implementor = new TestMtomJMSImpl();
    bus = BusFactory.getDefaultBus();
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
    PooledConnectionFactory cfp = new PooledConnectionFactory(cf);
    cff = new ConnectionFactoryFeature(cfp);
    EndpointImpl ep = (EndpointImpl) Endpoint.create(implementor);
    ep.getFeatures().add(cff);
    ep.getInInterceptors().add(new TestMultipartMessageInterceptor());
    ep.getOutInterceptors().add(new TestAttachmentOutInterceptor());
    // ep.getInInterceptors().add(new LoggingInInterceptor());
    // ep.getOutInterceptors().add(new LoggingOutInterceptor());
    SOAPBinding jaxWsSoapBinding = (SOAPBinding) ep.getBinding();
    jaxWsSoapBinding.setMTOMEnabled(true);
    ep.publish();
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) ConnectionFactoryFeature(org.apache.cxf.transport.jms.ConnectionFactoryFeature) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BeforeClass(org.junit.BeforeClass)

Example 22 with PooledConnectionFactory

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

the class MessageIdAsCorrelationIdJMSConduitTest method sendAndReceive.

public void sendAndReceive(boolean synchronous, String replyDestination) throws Exception {
    BusFactory bf = BusFactory.newInstance();
    Bus bus = bf.createBus();
    BusFactory.setDefaultBus(bus);
    EndpointReferenceType target = new EndpointReferenceType();
    connectionFactory = new PooledConnectionFactory(BROKER_URI);
    TestReceiver receiver = new TestReceiver(connectionFactory, SERVICE_QUEUE, true);
    receiver.runAsync();
    JMSConfiguration jmsConfig = new JMSConfiguration();
    jmsConfig.setTargetDestination(SERVICE_QUEUE);
    jmsConfig.setConnectionFactory(connectionFactory);
    jmsConfig.setUseConduitIdSelector(false);
    jmsConfig.setReplyDestination(replyDestination);
    JMSConduit conduit = new JMSConduit(target, jmsConfig, bus);
    Exchange exchange = new ExchangeImpl();
    exchange.setSynchronous(synchronous);
    Message message = new MessageImpl();
    exchange.setOutMessage(message);
    conduit.sendExchange(exchange, "Request");
    waitForAsyncReply(exchange);
    receiver.close();
    if (exchange.getInMessage() == null) {
        throw new RuntimeException("No reply received within 2 seconds");
    }
    JMSMessageHeadersType inHeaders = (JMSMessageHeadersType) exchange.getInMessage().get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
    Assert.assertEquals(receiver.getRequestMessageId(), inHeaders.getJMSCorrelationID());
    conduit.close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Message(org.apache.cxf.message.Message) BusFactory(org.apache.cxf.BusFactory) TestReceiver(org.apache.cxf.transport.jms.util.TestReceiver) Exchange(org.apache.cxf.message.Exchange) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 23 with PooledConnectionFactory

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

the class PooledConnectionTempQueueTest method testTempQueueIssue.

@Test
public void testTempQueueIssue() throws JMSException, InterruptedException {
    final PooledConnectionFactory cf = new PooledConnectionFactory("vm://localhost?broker.persistent=false");
    Connection con1 = cf.createConnection();
    con1.start();
    // This order seems to matter to reproduce the issue
    con1.close();
    Executors.newSingleThreadExecutor().execute(new Runnable() {

        public void run() {
            try {
                receiveAndRespondWithMessageIdAsCorrelationId(cf, SERVICE_QUEUE);
            } catch (JMSException e) {
                e.printStackTrace();
            }
        }
    });
    sendWithReplyToTemp(cf, SERVICE_QUEUE);
}
Also used : Connection(javax.jms.Connection) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) JMSException(javax.jms.JMSException) Test(org.junit.Test)

Example 24 with PooledConnectionFactory

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

the class ActivemqConfiguration method init.

@PostConstruct
public void init() {
    String brokerClusterString = ConnectionFactoryContainer.buildProducerBrokerClusterUri(Constans.PRODUCER_BROKER_URL);
    PooledConnectionFactory pooledConnectionFactory = ConnectionFactoryContainer.getPooledConnectionFactory(brokerClusterString);
    JmsTemplate jmsTemplate = new JmsTemplate(pooledConnectionFactory);
    QueueJmsTemplateContainer.setQueJmsTemplateMap(Constans.QUEUE_NAME, jmsTemplate);
}
Also used : PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) JmsTemplate(org.springframework.jms.core.JmsTemplate) PostConstruct(javax.annotation.PostConstruct)

Example 25 with PooledConnectionFactory

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

the class ConnectionFactoryContainer method producerConnectionFactoryResetExpiryTimeout.

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

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