activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nixen09 <nixe...@gmail.com>
Subject How to get the message from temporary Queue in Different session
Date Tue, 05 Nov 2013 09:09:37 GMT
i am new to jms and activemq. i produce one message to one static queue in
activemq and get reply back to temporary queue using getJMSReplyTo. the code
is following

ActiveMQConnectionFactory connectionFactory = new 
ActiveMQConnectionFactory("tcp://localhost:61616");

    // Create a Connection
    Connection connection = connectionFactory.createConnection();
    connection.start();

    // Create a Session
    Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);


    // Create the destination (Topic or Queue)
    Destination destination = (Destination)  
session.createQueue("PostWithParameter_Queue");

    // Create a MessageConsumer from the Session to the Topic or Queue
    MessageConsumer consumer = session.createConsumer(destination);
    //consumer.setMessageListener(new StaticQueueListener());
    // Wait for a message
    Message message = (Message) consumer.receive();
    MessageConsumer consumer1 =
session.createConsumer(message.getJMSReplyTo());
    consumer1.setMessageListener(new ReplyHandler()); 
    consumer.close();
    session.close();

My Reply Handler follows

@Override
public void onMessage(Message message) {

    try
    {

        System.out.println(message.getStringProperty("status"));
    }
    catch (JMSException e) 
    {
            e.printStackTrace();
    }
}  

Now i am getting the result from temporary queue. because its in the same
session. my question is i want to get the message from temporary queue in
differesnt session using temporary queue name. if i want to get the message
from temporary queue in different client using temporary queue name how i
will do that ? .
when i try to do that in normal way it creating one queue.



--
View this message in context: http://activemq.2283324.n4.nabble.com/How-to-get-the-message-from-temporary-Queue-in-Different-session-tp4673886.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message