Search in sources :

Example 81 with Destination

use of javax.jms.Destination in project cxf by apache.

the class JAXRSJmsTest method testAddGetBook.

@Test
public void testAddGetBook() throws Exception {
    Context ctx = getContext();
    ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
    Destination destination = (Destination) ctx.lookup("dynamicQueues/test.jmstransport.text");
    Destination replyToDestination = (Destination) ctx.lookup("dynamicQueues/test.jmstransport.response");
    Connection connection = null;
    try {
        connection = factory.createConnection();
        connection.start();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        postBook(session, destination, replyToDestination);
        checkBookInResponse(session, replyToDestination, 124L, "JMS");
        session.close();
    } finally {
        close(connection);
    }
}
Also used : Context(javax.naming.Context) JAXBContext(javax.xml.bind.JAXBContext) InitialContext(javax.naming.InitialContext) Destination(javax.jms.Destination) ConnectionFactory(javax.jms.ConnectionFactory) Connection(javax.jms.Connection) Session(javax.jms.Session) Test(org.junit.Test)

Example 82 with Destination

use of javax.jms.Destination in project cxf by apache.

the class SOAPJMSTestSuiteTest method twoWayTestWithCreateMessage.

public void twoWayTestWithCreateMessage(final TestCaseType testcase) throws Exception {
    String address = testcase.getAddress();
    EndpointInfo endpointInfo = new EndpointInfo();
    endpointInfo.setAddress(JMSTestUtil.getFullAddress(address, broker.getBrokerURL()));
    JMSConfiguration jmsConfig = JMSConfigFactory.createFromEndpointInfo(staticBus, endpointInfo, null);
    ResourceCloser closer = new ResourceCloser();
    try {
        Connection connection = closer.register(JMSFactory.createConnection(jmsConfig));
        connection.start();
        Session session = closer.register(connection.createSession(false, Session.AUTO_ACKNOWLEDGE));
        Destination targetDest = jmsConfig.getTargetDestination(session);
        Destination replyToDestination = jmsConfig.getReplyToDestination(session, null);
        JMSSender sender = JMSFactory.createJmsSender(jmsConfig, null);
        Message jmsMessage = JMSTestUtil.buildJMSMessageFromTestCase(testcase, session, replyToDestination);
        sender.sendMessage(session, targetDest, jmsMessage);
        Message replyMessage = JMSUtil.receive(session, replyToDestination, jmsMessage.getJMSMessageID(), 10000, true);
        checkReplyMessage(replyMessage, testcase);
    } catch (JMSException e) {
        throw JMSUtil.convertJmsException(e);
    } finally {
        closer.close();
    }
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Destination(javax.jms.Destination) JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) Message(javax.jms.Message) Connection(javax.jms.Connection) ResourceCloser(org.apache.cxf.transport.jms.util.ResourceCloser) JMSSender(org.apache.cxf.transport.jms.util.JMSSender) JMSException(javax.jms.JMSException) Session(javax.jms.Session)

Example 83 with Destination

use of javax.jms.Destination in project vcell by virtualcell.

the class VCMessagingServiceActiveMQ method createConsumer.

@Override
public MessageConsumer createConsumer(Session jmsSession, VCDestination vcDestination, VCMessageSelector vcSelector, int prefetchLimit) throws JMSException {
    Destination jmsDestination;
    MessageConsumer jmsMessageConsumer;
    if (vcDestination instanceof VCellQueue) {
        jmsDestination = jmsSession.createQueue(vcDestination.getName() + "?consumer.prefetchSize=" + prefetchLimit);
    } else {
        jmsDestination = jmsSession.createTopic(vcDestination.getName() + "?consumer.prefetchSize=" + prefetchLimit);
    }
    if (vcSelector == null) {
        jmsMessageConsumer = jmsSession.createConsumer(jmsDestination);
    } else {
        jmsMessageConsumer = jmsSession.createConsumer(jmsDestination, vcSelector.getSelectionString());
    }
    return jmsMessageConsumer;
}
Also used : VCDestination(cbit.vcell.message.VCDestination) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) VCellQueue(cbit.vcell.message.VCellQueue)

Example 84 with Destination

use of javax.jms.Destination in project vcell by virtualcell.

the class QueueWatcher method start.

public void start() throws JMSException {
    ActiveMQTopic[] tpcs = AdvisorySupport.getAllDestinationAdvisoryTopics(queue);
    for (ActiveMQTopic tp : tpcs) {
        writer.println("watching " + tp.getTopicName());
        Destination ds = session.createTopic(tp.getPhysicalName());
        MessageConsumer c = session.createConsumer(ds);
        c.setMessageListener(new AdvListener(tp.getTopicName()));
    }
}
Also used : Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic)

Example 85 with Destination

use of javax.jms.Destination in project vcell by virtualcell.

the class VCMessagingServiceEmbedded method createConsumer.

@Override
public MessageConsumer createConsumer(Session jmsSession, VCDestination vcDestination, VCMessageSelector vcSelector, int prefetchLimit) throws JMSException, VCMessagingException {
    if (!initialized) {
        initialized = true;
        init();
    }
    Destination jmsDestination;
    MessageConsumer jmsMessageConsumer;
    if (vcDestination instanceof VCellQueue) {
        jmsDestination = jmsSession.createQueue(vcDestination.getName() + "?consumer.prefetchSize=" + prefetchLimit);
    } else {
        jmsDestination = jmsSession.createTopic(vcDestination.getName() + "?consumer.prefetchSize=" + prefetchLimit);
    }
    if (vcSelector == null) {
        jmsMessageConsumer = jmsSession.createConsumer(jmsDestination);
    } else {
        jmsMessageConsumer = jmsSession.createConsumer(jmsDestination, vcSelector.getSelectionString());
    }
    return jmsMessageConsumer;
}
Also used : VCDestination(cbit.vcell.message.VCDestination) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) VCellQueue(cbit.vcell.message.VCellQueue)

Aggregations

Destination (javax.jms.Destination)178 Test (org.junit.Test)51 TextMessage (javax.jms.TextMessage)47 Session (javax.jms.Session)46 JMSException (javax.jms.JMSException)45 Connection (javax.jms.Connection)32 MessageProducer (javax.jms.MessageProducer)31 Message (javax.jms.Message)30 ConnectionFactory (javax.jms.ConnectionFactory)24 MessageConsumer (javax.jms.MessageConsumer)24 JMSContext (javax.jms.JMSContext)16 CountDownLatch (java.util.concurrent.CountDownLatch)15 ObjectMessage (javax.jms.ObjectMessage)12 StubTextMessage (org.springframework.jms.StubTextMessage)11 InitialContext (javax.naming.InitialContext)10 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)10 Queue (javax.jms.Queue)8 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)8 MapMessage (javax.jms.MapMessage)7 HashMap (java.util.HashMap)6