title: IBM MQ Error 2009 - How to detect when Queue Manager seems to spin up its own thread
body: <p>This is bizarre and somewhat worrying for reliable messaging. I'm hoping I'm missing something.</p>
  
  <p>This has only come to light today due to known network failures. It's giving me a good opportunity to have a look at some fault tolerance.</p>
  
  <p>On thread 1, we send a message on a Queue managed by a Queue Manager. This code:</p>
  
  <pre><code>using (MQQueueManager qMgr = new MQQueueManager(_queueManager, _connectionProperties))
  {
   // send message
  }
  </code></pre>
  
  <p>Just "hangs" on the Queue Manager. As in, it seems to run and then timesout. Maybe it runs on a thread and the thread crashes.</p>
  
  <p>We wouldn't have known anything except we have a second thread listening to another queue.</p>
  
  <p>We have the same construct on the receive thread:</p>
  
  <pre><code>using (MQQueueManager qMgr = new MQQueueManager(_queueManager, _connectionProperties))
  {
   // listen for message
  }
  </code></pre>
  
  <p>But this throws an <code>MQException</code> with error code 2009. This suggests a network issue. (<a href="http://www-01.ibm.com/support/docview.wss?uid=swg21472342" rel="nofollow noreferrer">http://www-01.ibm.com/support/docview.wss?uid=swg21472342</a>)</p>
  
  <p>However, again, the <code>QueueManager</code> on the second thread seems to spin up its own thread on which the exception is thrown, resulting in no ability to catch it and react.</p>
  
  <p>Is there something we're missing?</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>Here are my connection properties:</p>
  
  <pre><code>Hashtable connectionProperties = new Hashtable();
  connectionProperties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
  connectionProperties.Add(MQC.USE_MQCSP_AUTHENTICATION_PROPERTY, true);
  connectionProperties.Add(MQC.HOST_NAME_PROPERTY, hostName);
  connectionProperties.Add(MQC.CHANNEL_PROPERTY, channel);
  connectionProperties.Add(MQC.PORT_PROPERTY, portNumber);
  connectionProperties.Add(MQC.CONNECT_OPTIONS_PROPERTY, MQC.MQCNO_RECONNECT_Q_MGR);
  return connectionProperties;
  </code></pre>
  
  <p>Bearing in mind I am a novice at IBM MQ, I notice that I have the connection property <code>MQC.MQCNO_RECONNECT_Q_MGR</code>. Will this play a role? I'm aiming for knowing and managing when things go wrong as opposed to relying on something we don't entirely understand. </p>