title: ActiveMQ: How to handle broker failovers while using temporary queues
body: <p>On my JMS applications we use temporary queues on Producers to be able to receive replies back from Consumer applications.</p>
  <p>I am facing exactly same issue on my end as mentioned in this thread: <a href="http://activemq.2283324.n4.nabble.com/jira-Created-AMQ-3336-Temporary-Destination-errors-on-H-A-failover-in-broker-network-with-Failover-tt-td3551034.html#a3612738" rel="noreferrer">http://activemq.2283324.n4.nabble.com/jira-Created-AMQ-3336-Temporary-Destination-errors-on-H-A-failover-in-broker-network-with-Failover-tt-td3551034.html#a3612738</a></p>
  <p>Whenever I restarted an arbitrary broker in my network, I was getting many errors like this in my Consumer application log while trying to send reply to a temporary queue:</p>
  <pre><code>javax.jms.InvalidDestinationException:
    Cannot publish to a deleted Destination: temp-queue://ID:...
  </code></pre>
  <p>Then I saw Gary's response there suggesting to use</p>
  <pre><code>jms.watchTopicAdvisories=false
  </code></pre>
  <p>as a url param on the client <code>brokerURL</code>. I promptly changed my client broker URLs with this additional parameter. However now I am seeing errors like this when I restart my brokers in network for this failover testing:</p>
  <pre><code>javax.jms.JMSException: 
    The destination temp-queue:
      //ID:client.host-65070-1308610734958-2:1:1 does not exist.
  </code></pre>
  <p>I am using ActiveMQ 5.5 version. And my client broker URL looks like this:</p>
  <pre><code>failover:(tcp://amq-host1:61616,tcp://amq-host2.tred.aol.com:61616,tcp://amq-host3:61616,tcp://amq-host4:61616)?jms.useAsyncSend=true&amp;timeout=5000&amp;jms.watchTopicAdvisories=false
   
  </code></pre>
  <p>Additionally here is my activemq config XML for one of the 4 brokers:
  <a href="http://activemq.2283324.n4.nabble.com/file/n3612738/amq1.xml" rel="noreferrer">amq1.xml</a></p>
  <p>Can someone here please look into this problem and suggest me what mistake I am making in this setup.</p>
  <h1>Update:</h1>
  <p>To clarify further on how I am doing request-response in my code:</p>
  <ol>
  <li>I already use a per producer destination (i.e. temporary queue) and set this in reply-to header of every message.</li>
  <li>I am already sending a per message unique correlation identifier in JMSCorrelationID header.</li>
  <li>As far as I know even Camel and Spring are also using temporary queue for request-response mechanism. Only difference is that Spring JMS implementation creates and destroys temporary queue for every message whereas I create temporary queue for the lifetime of the producer. This temporary queue is destroyed when client (producer) app shutsdown or by the AMQ broker when it realizes there are no active producer attached with this temporary queue.</li>
  <li>I am already setting a message expiry on each message on Producer side so that message is not held up in a queue for too long (60 sec).</li>
  </ol>