Ejemplo n.º 1
0
        private void RetryOnHCONNError(Action action)
        {
            int tries = MaxRetryOnHConnError;

            while (true)
            {
                try
                {
                    if (tries < MaxRetryOnHConnError)
                    {
                        IbmQueueManager.Connect();
                    }

                    action();
                    return;
                }
                catch (MQException ex)
                {
                    if (ex.ReasonCode == MQC.MQRC_HCONN_ERROR ||
                        ex.ReasonCode == MQC.MQRC_CONNECTION_BROKEN)
                    {
                        tries--;
                        if (tries == 0)
                        {
                            throw;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        internal MQQueue OpenQueueCore(string queueName, OpenQueueMode openMode)
        {
            Debug.Assert(!string.IsNullOrEmpty(queueName));

            var openFlags = MQC.MQOO_FAIL_IF_QUIESCING;

            switch (openMode)
            {
            case OpenQueueMode.ForBrowse:
                openFlags = openFlags | MQC.MQOO_BROWSE;
                break;

            case OpenQueueMode.ForBrowseCo:
                openFlags = openFlags | MQC.MQOO_CO_OP | MQC.MQOO_BROWSE;
                break;

            case OpenQueueMode.ForSet:
                openFlags = openFlags | MQC.MQOO_SET;
                break;

            case OpenQueueMode.ForRead:
                openFlags = openFlags | MQC.MQOO_INPUT_SHARED;
                break;

            case OpenQueueMode.ForWrite:
                openFlags = openFlags | MQC.MQOO_OUTPUT;
                break;

            case OpenQueueMode.ForWriteSetAllContext:
                openFlags = openFlags | MQC.MQOO_OUTPUT | MQC.MQOO_SET_ALL_CONTEXT;
                break;

            case OpenQueueMode.ForWriteSetIdentityContext:
                openFlags = openFlags | MQC.MQOO_OUTPUT | MQC.MQOO_SET_IDENTITY_CONTEXT;
                break;

            case OpenQueueMode.ForWritePassAllContext:
                openFlags = openFlags | MQC.MQOO_OUTPUT | MQC.MQOO_PASS_ALL_CONTEXT;
                break;

            case OpenQueueMode.ForWritePassIdentityContext:
                openFlags = openFlags | MQC.MQOO_OUTPUT | MQC.MQOO_PASS_IDENTITY_CONTEXT;
                break;

            case OpenQueueMode.ForQuery:
                openFlags = openFlags | MQC.MQOO_INQUIRE;
                break;

            case OpenQueueMode.ForBrowseAndRead:
                openFlags = openFlags | MQC.MQOO_BROWSE | MQC.MQOO_INPUT_SHARED;
                break;
            }

            return(RetryOnHCONNError(() =>
            {
                return IbmQueueManager.AccessQueue(queueName, openFlags);
            }));
        }
Ejemplo n.º 3
0
 public void Rollback()
 {
     try
     {
         IbmQueueManager.Backout();
     }
     catch (MQException ibmEx)
     {
         throw ibmEx.ToMqException(AddExtraInfoToError);
     }
 }
Ejemplo n.º 4
0
 public void Commit()
 {
     try
     {
         IbmQueueManager.Commit();
     }
     catch (MQException ibmEx)
     {
         throw ibmEx.ToMqException(AddExtraInfoToError);
     }
 }