title: IBM MQ.NET Send Message Asynchronously and Commit()
body: <p>I tried to verify the speed of using both async <code>Put()</code> and <code>Commit()</code> using the code below. The problem is that its speed is ten times slower than either using async <code>Put()</code> only or <code>Commit()</code> only, which does not make sense. </p>
  
  <p>Am I missing something here?</p>
  
  <pre><code>class AsyncProducerWithCommit 
      {
          private MQQueueManager _queueManager;
          private MQQueue _queue;
  
          public void Run()
          {
              Produce();
          }
  
  
          void Produce()
          {
              Open(ConnectionMode.Write);
  
              PutMessage(ConvertMessageToByte(message)); 
  
              _queue.Close();
              _queueManager.Disconnect();
          }
  
          void PutMessage(byte[] messageString)
          {          
              MQMessage _message = new MQMessage();
              _message.Write(messageString);
              _message.Format = MQC.MQFMT_STRING;
              _message.CharacterSet = 1208;// IbmUtf8Encoding;
              _message.Persistence = MQC.MQPER_PERSISTENT;
  
              var putMessageOptions = new MQPutMessageOptions();
              putMessageOptions.Options  =  MQC.MQPMO_SYNCPOINT    //unit of work
                                            + MQC.MQPMO_ASYNC_RESPONSE;  //async
  
              _queue.Put(_message, putMessageOptions); //send message asynchronously
  
               _queueManager.Commit();   
  
          }
  
          void Open(ConnectionMode connectionMode)
          {
              string _queueManagerName = _appSetting.MessagingServerSetting.QueueManagerName;
  
              int openOptions = 0;
  
              switch (connectionMode)
              {
                  case ConnectionMode.Read:
                      openOptions = MQC.MQOO_INPUT_SHARED + MQC.MQOO_FAIL_IF_QUIESCING;
                      break;
                  case ConnectionMode.Write:
                      openOptions = MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING;
                      break;
              }
  
  
              var properties = new Hashtable
              {
                  {MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED },
                  {MQC.CONNECT_OPTIONS_PROPERTY, MQC.MQCNO_RECONNECT },
                  { MQC.HOST_NAME_PROPERTY, "192.168.1.10" },
                  { MQC.PORT_PROPERTY, "1415"},
                  { MQC.CHANNEL_PROPERTY, "LOCAL.DEF.SVRCONN" },
                  {MQC.USER_ID_PROPERTY, "user" },
                  {MQC.PASSWORD_PROPERTY, "pwd" }               
              };
  
              _queueManager = new MQQueueManager(_queueManagerName, properties);
              _queue = _queueManager.AccessQueue(QUEUE_NAME, openOptions);
          }
  
  
          public enum ConnectionMode
          {
              Read,
              Write
          }
  
      }
  </code></pre>
  
  <p><strong>Update 1</strong></p>
  
  <p>Async Put</p>
  
  <pre><code> putMessageOptions.Options  =  MQC.MQPMO_ASYNC_RESPONSE;  //async
  _queue.Put(_message, putMessageOptions); //send message asynchronously
  </code></pre>
  
  <p>Put with Commit</p>
  
  <pre><code> putMessageOptions.Options  =  MQC.MQPMO_SYNCPOINT;    //unit of work                                         
    _queue.Put(_message, putMessageOptions); 
   _queueManager.Commit(); 
  </code></pre>
  
  <p>QueueManager version: 8.0.0.5 on Redhat Linux 7+</p>
  
  <p>MQ.NET: 8.0.0.8</p>