You should always use the name provided by JMSReplyTo header. It shouldn't make a difference which session you're using. Temporary destination lifecycle (creation, and removal) are tied to the connection that created it, so you'd have to verify the connection is still around when you're using the temporary destination.
On Tue, Nov 5, 2013 at 2:09 AM, nixen09 <[email protected]> wrote: > 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. -- Christian Posta http://www.christianposta.com/blog twitter: @christianposta
