Ejemplo n.º 1
0
        internal void RunRecovery()
        {
            uint method = 0x521;

            this.TrEntry(method);
            int  num2 = 0;
            bool flag = false;

            while ((num2 = this.Queue.CurrentDepth) > 0)
            {
                flag = true;
                log.WriteLog("SYSTEM.DOTNET.XARECOVERY.QUEUE Current Depth : ", num2.ToString());
                MQMessage message = new MQMessage();
                try
                {
                    this.Queue.Get(message, this.gmoB);
                }
                catch (MQException exception)
                {
                    base.TrException(method, exception, 1);
                    if (exception.Reason == 0x7f1)
                    {
                        break;
                    }
                }
                log.WriteLog("MsgID of current message(recovery message) being processed ", NmqiTools.ArrayToHexString(message.MessageId));
                if (message == null)
                {
                    break;
                }
                sbyte[] xid            = null;
                double  doubleProperty = 0.0;
                string  stringProperty = null;
                try
                {
                    xid            = message.GetBytesProperty("dnet.XARECOVERY_XID");
                    doubleProperty = message.GetDoubleProperty("dnet.XARECOVERY_TTIMEOUT");
                    stringProperty = message.GetStringProperty("dnet.XARECOVERY_HOSTANDUSER");
                }
                catch (MQException exception2)
                {
                    base.TrException(method, exception2, 2);
                    if ((((exception2.Reason != 0x9a7) && (exception2.Reason != 0x98a)) && ((exception2.Reason != 0x9a2) && (exception2.Reason != 0x9a3))) && ((exception2.Reason != 0x9a6) && (exception2.Reason != 0x9a5)))
                    {
                        throw exception2;
                    }
                    continue;
                }
                log.WriteLog("Host,UserId under which the Transaction Recovery message has been put : " + stringProperty);
                log.WriteLog("Current Xid from the indoubt message");
                log.WriteXid(xid);
                DateTime putDateTime = message.PutDateTime;
                DateTime time2       = putDateTime.AddMilliseconds(doubleProperty);
                if (time2 > DateTime.Now)
                {
                    log.WriteLog("TransactionTimeout - " + time2.ToLongTimeString());
                    log.WriteLog("Message arrival time - " + putDateTime.ToLongTimeString());
                    log.WriteLog("Monitor skiping the current messages as transaction did not timeout yet..");
                }
                else
                {
                    try
                    {
                        this.Queue.Get(message, this.gmoG);
                        log.WriteLog("Found one Inomplete Transaction from message,(ID):", NmqiTools.ArrayToHexString(message.MessageId));
                    }
                    catch (MQException exception3)
                    {
                        base.TrException(method, exception3, 2);
                        throw exception3;
                    }
                    try
                    {
                        int     intProperty   = message.GetIntProperty("dnet.XARECOVERY_RMID");
                        sbyte[] bytesProperty = message.GetBytesProperty("dnet.XARECOVERY_QMID");
                        sbyte[] recinfo       = message.GetBytesProperty("dnet.XARECOVERY_RECINFO");
                        sbyte[] numArray4     = message.GetBytesProperty("dnet.XARECOVERY_XID");
                        byte[]  dst           = new byte[bytesProperty.Length];
                        Buffer.BlockCopy(bytesProperty, 0, dst, 0, dst.Length);
                        this.QMId = new Guid(dst);
                        if (this.RecoverTransaction(this.QMId, recinfo, numArray4, intProperty))
                        {
                            this.Qmgr.Commit();
                            if (!CompletedQMId.Contains(this.QMId))
                            {
                                CompletedQMId.Add(this.QMId);
                            }
                        }
                        else
                        {
                            if (CompletedQMId.Contains(this.QMId))
                            {
                                CompletedQMId.Remove(this.QMId);
                            }
                            this.Qmgr.Backout();
                        }
                        continue;
                    }
                    catch (MQException exception4)
                    {
                        base.TrException(method, exception4, 3);
                        throw exception4;
                    }
                }
            }
            foreach (Guid guid in CompletedQMId)
            {
                TransactionManager.RecoveryComplete(guid);
            }
            if (!flag)
            {
                Thread.Sleep(0x1d4c0);
                this.reenter = true;
            }
            base.TrExit(method);
        }