title: javax.jms.InvalidDestinationException: Cannot use a Temporary destination from another Connection
body: <p>I have a producer which connects to ActiveMQ broker to send me messages to the client.</p>
  
  <ol>
  <li>Since it expects some response from the client, it first creates a temp queue and associates it to the <strong>JMS replyto</strong> header. </li>
  <li>It then sends the message over to the broker and waits for the response on temp queue from the client.</li>
  <li>Receives the response from the client over the temp queue, performs required actions and then exits.</li>
  </ol>
  
  <p>This works fine most of the times, but sporadically the application throws error messsages saying " Cannot use queue created from another connection ".</p>
  
  <p>I am unable to identify what could cause this to happen as the temp queue is being created from the current session itself.</p>
  
  <p>Did anyone else come across this situation and knows how to fix it?</p>
  
  <p>Code snippet:</p>
  
  <pre><code>Connection conn = myJmsTemp. getConnectionFactory().createConnection();
  ses = conn.createSession(transacted,ackMode);
  responseQueue = ses.createTemporaryQueue();
  ...
  MyMessageCreator msgCrtr = new MyMessageCreator(objects,responseQueue);
  myJmsTemp.send(dest, msgCrtr);
  myJmsTemp.setReceiveTimeout(timeout);
  ObjectMessage response = (ObjectMessage)myJmsTemplate.receive(responseQueue);
  </code></pre>
  
  <p>Here <code>MyMessageCreator</code> implements <code>MessageCreator</code> interface.</p>
  
  <p>All am trying to do is send a message to the broker and wait for a response from the client over the temp queue. Also am using a pooled connection factory to get the connection.</p>