internal void EnlistTransactionIntoDtc()
        {
            uint method = 0x4f8;

            this.TrEntry(method);
            try
            {
                base.TrText(method, "ResourceManager Id:- " + NmqiTools.ArrayToHexString(this.myGuid.ToByteArray()));
                base.TrText(method, "Hconn = " + base.hconn.Value);
                base.TrText(method, "Enlisting as Durable Resource manager into Current Transaction");
                base.InitializeMQRMI();
                Transaction.Current.EnlistDurable(base.myGuid, (ISinglePhaseNotification)this, EnlistmentOptions.EnlistDuringPrepareRequired);
                base.TrText(method, "WMQ .NET Enlisted as Resource Manager with Transaction Co-ordinator");
                base.hconn.currentTransaction = Transaction.Current;
                base.TrText(method, "Current Transaction's Information");
                base.TrText(method, "DistributedIdentifier:- " + NmqiTools.ArrayToHexString(Transaction.Current.TransactionInformation.DistributedIdentifier.ToByteArray()));
                base.TrText(method, "LocalIdentifier:- " + Transaction.Current.TransactionInformation.LocalIdentifier);
            }
            catch (MQException exception)
            {
                base.TrException(method, exception, 1);
                throw exception;
            }
            catch (TransactionException exception2)
            {
                base.TrException(method, exception2, 2);
                MQException exception3 = new MQException(2, 0x932, exception2);
                throw exception3;
            }
            finally
            {
                base.TrExit(method);
            }
        }
Esempio n. 2
0
        public static int GetLengthV2(int ptrSize)
        {
            int num  = (GetLengthV1(ptrSize) + 20) + (3 * ptrSize);
            int num2 = NmqiTools.Padding(ptrSize, 0, 4, 12);

            return(num + num2);
        }
        private void MQRMIXAStart()
        {
            uint method = 0x50f;

            this.TrEntry(method);
            int num2 = 0;

            try
            {
                base.TrText(method, "Hconn value = " + this.hconn.Value + " issuing xa_start");
                this.xid.TraceFields();
                num2 = this.hconn.Session.MQFap.XA_Start(this.hconn, this.xid, this.hconn.Rmid, 0);
                if ((num2 != 0) && (num2 != 3))
                {
                    TransactionException innerException = new TransactionException(NmqiTools.GetTranslatedExceptionMessage(this.ToString(), 0x20008385, (uint)num2));
                    MQException          exception2     = new MQException(2, 0x893, innerException);
                    CommonServices.SetValidInserts();
                    CommonServices.ArithInsert1   = (uint)this.hconn.Rmid;
                    CommonServices.CommentInsert1 = "xa_start call has failed with return code = " + num2;
                    base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                    throw exception2;
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
        public void MQRMIXARollback()
        {
            uint method = 0x514;

            this.TrEntry(method);
            int flags = 0;

            try
            {
                base.TrText(method, "Hconn value = " + this.hconn.Value + " issuing xa_rollback");
                this.xid.TraceFields();
                int num2 = this.hconn.Session.MQFap.XA_Rollback(this.hconn, this.xid, this.hconn.Rmid, flags);
                if (num2 != 0)
                {
                    TransactionException innerException = new TransactionException(NmqiTools.GetTranslatedExceptionMessage(this.ToString(), 0x20008385, (uint)num2));
                    MQException          exception2     = new MQException(2, 0x893, innerException);
                    CommonServices.SetValidInserts();
                    CommonServices.ArithInsert1   = (uint)this.hconn.Rmid;
                    CommonServices.CommentInsert1 = "xa_rollback call has failed with return code = " + num2;
                    base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                    throw exception2;
                }
                base.TrText(method, "Hconn value = " + this.hconn.Value + " issuing MQGET to remove recovery message.");
                this.hconn.XARecoveryBridge.LogCurrentTransactionEnd(this.xid, this.hconn.Rmid);
            }
            finally
            {
                base.TrExit(method);
            }
        }
Esempio n. 5
0
        internal void UpdateHconn(NmqiMQ mqInstance, Phconn phconn)
        {
            uint method = 0x2f9;

            this.TrEntry(method, new object[] { mqInstance, phconn });
            try
            {
                this.MQI = mqInstance;
                Hconn hconn = null;
                switch (this.value_)
                {
                case -1:
                    hconn = new HconnAdapter(-1);
                    break;

                case 0:
                    hconn = new HconnAdapter(0);
                    break;

                default:
                    hconn = this;
                    if (this.qMgrInfo == null)
                    {
                        this.qMgrInfo = NmqiTools.GetQueueManagerInfo(base.env, mqInstance, this);
                    }
                    break;
                }
                phconn.HConn = hconn;
            }
            finally
            {
                base.TrExit(method);
            }
        }
        public void MQRMIXACommit(bool onephase)
        {
            uint method = 0x513;

            this.TrEntry(method, new object[] { onephase });
            int flags = onephase ? 0x40000000 : 0;

            try
            {
                base.TrText(method, "Hconn value = " + this.hconn.Value + " issuing xa_commit");
                this.xid.TraceFields();
                int num3 = this.hconn.Session.MQFap.XA_Commit(this.hconn, this.xid, this.hconn.Rmid, flags);
                if ((num3 != 0) && (num3 != 3))
                {
                    TransactionException innerException = new TransactionException(NmqiTools.GetTranslatedExceptionMessage(this.ToString(), 0x20008385, (uint)num3));
                    MQException          exception2     = new MQException(2, 0x893, innerException);
                    CommonServices.SetValidInserts();
                    CommonServices.ArithInsert1   = (uint)this.hconn.Rmid;
                    CommonServices.CommentInsert1 = "xa_commit call has failed with return code = " + num3;
                    base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                    throw exception2;
                }
                if (!onephase)
                {
                    base.TrText(method, "Hconn value = " + this.hconn.Value + " issuing MQGET to remove recovery message.");
                    this.hconn.XARecoveryBridge.LogCurrentTransactionEnd(this.xid, this.hconn.Rmid);
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
Esempio n. 7
0
        public static int GetLengthV1(int ptrSize)
        {
            int num  = 120 + (2 * ptrSize);
            int num2 = NmqiTools.Padding(ptrSize, 0, 8, 0x18);

            return(num + num2);
        }
        internal void WriteXid(sbyte[] xid)
        {
            int           index   = 0;
            StringBuilder builder = new StringBuilder();

            builder.Append("[XID]");
            byte[] dst = new byte[xid.Length];
            Buffer.BlockCopy(xid, 0, dst, 0, xid.Length);
            int num2 = BitConverter.ToInt32(dst, 0);

            index += 4;
            builder.AppendLine(" formatId : " + num2);
            builder.Append("                                   ");
            int length = dst[index];

            index++;
            int num4 = dst[index];

            index++;
            builder.Append("[gtrid]: ");
            string str = NmqiTools.ToString(dst, index, length);

            builder.AppendLine(string.Format("{0,30}", str));
            index += length;
            builder.Append("                                   ");
            builder.Append("[bqual]: ");
            string str2 = NmqiTools.ToString(dst, index, num4);

            builder.Append(string.Format("{0,30}", str2));
            index += num4;
            this.WriteLog(builder.ToString());
        }
Esempio n. 9
0
        public void Add(string name, long value)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(NmqiTools.Left(Convert.ToString(value), 1));
            builder.Append(NmqiTools.Left(" (hex ", 1));
            builder.Append(value.ToString("X"));
            builder.Append(NmqiTools.Left(")", 1));
            this.AddField("", "", name, builder.ToString());
        }
Esempio n. 10
0
        private void AddField(string lquote, string rquote, string name, string value)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(NmqiTools.Left(name, this.width1));
            builder.Append(NmqiTools.Left(":", this.width2));
            builder.Append(lquote);
            builder.Append(value);
            builder.Append(rquote);
            this.fields.Add(builder.ToString());
        }
Esempio n. 11
0
        public void Run()
        {
            uint method = 0x4c1;

            this.TrEntry(method);
            Thread.CurrentThread.Name = "ReconnectThread";
            Thread.SetData(Thread.GetNamedDataSlot("MQ_CLIENT_THREAD_TYPE"), 3);
            try
            {
                while (true)
                {
                    ManagedHconn remoteHconn = this.BestHconn();
                    base.TrText(method, "Hconn found for reconnection = " + remoteHconn.Value);
                    if (this.Reconnect(remoteHconn))
                    {
                        this.ReconnectionComplete(remoteHconn);
                        base.TrText(method, "Reconnection Completed");
                    }
                    else if (remoteHconn.HasFailed())
                    {
                        this.ReleaseHconn(remoteHconn);
                    }
                    else
                    {
                        remoteHconn.ReconnectionAttempts++;
                        int index = remoteHconn.ReconnectionAttempts - 1;
                        if (index >= this.rcnTimes.Length)
                        {
                            index = this.rcnTimes.Length - 1;
                        }
                        remoteHconn.NextReconnect = NmqiTools.GetCurrentTimeInMs() + Convert.ToInt64(this.rcnTimes[index]);
                        base.TrText(method, string.Concat(new object[] { "Reconnection details: Hconn : ", remoteHconn.Value, " Reconnection times : ", remoteHconn.ReconnectionAttempts, "NextReconnectionTime : ", remoteHconn.NextReconnect }));
                    }
                }
            }
            catch (Exception exception)
            {
                base.TrException(method, exception);
                CommonServices.SetValidInserts();
                CommonServices.ArithInsert1   = 1;
                CommonServices.CommentInsert1 = "ReconnectThread::Run";
                CommonServices.CommentInsert2 = exception.Message;
                CommonServices.CommentInsert3 = exception.StackTrace;
                base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009546, 0);
            }
            finally
            {
                Thread.SetData(Thread.GetNamedDataSlot("MQ_CLIENT_THREAD_TYPE"), 0);
                base.TrExit(method);
            }
        }
Esempio n. 12
0
 public void Add(string name, string[] value)
 {
     if (value != null)
     {
         StringBuilder builder = new StringBuilder();
         builder.Append(NmqiTools.Left(name, this.width1));
         builder.Append(":");
         for (int i = 0; i < value.Length; i++)
         {
             builder.Append("(" + value + ")");
         }
         this.fields.Add(builder.ToString());
     }
 }
Esempio n. 13
0
        internal MQTSH ReceiveAsyncTSH()
        {
            uint method = 0x61a;

            this.TrEntry(method);
            MQTSH result = null;

            try
            {
                lock (this.asyncTshLock)
                {
                    while ((this.asyncTshQueue.Count == 0) && (this.asyncFailure == null))
                    {
                        try
                        {
                            long currentTimeInMs     = NmqiTools.GetCurrentTimeInMs();
                            int  millisecondsTimeout = 10;
                            Monitor.Wait(this.asyncTshLock, millisecondsTimeout, true);
                            if ((NmqiTools.GetCurrentTimeInMs() >= (currentTimeInMs + millisecondsTimeout)) && !this.Connection.IsConnected)
                            {
                                NmqiException ex = new NmqiException(base.env, 0x23fd, null, 2, 0x7d9, null);
                                base.TrException(method, ex);
                                throw ex;
                            }
                            continue;
                        }
                        catch (ThreadInterruptedException exception2)
                        {
                            base.TrException(method, exception2);
                            continue;
                        }
                    }
                    if (this.asyncFailure != null)
                    {
                        this.connectionBroken = true;
                        this.hconn.RaiseEvent(0x7d9);
                        NmqiException exception3 = new NmqiException(base.env, -1, null, 2, 0x7d9, this.asyncFailure);
                        base.TrException(method, exception3);
                        throw exception3;
                    }
                }
                result = this.asyncTshQueue.Dequeue();
            }
            finally
            {
                base.TrExit(method, result);
            }
            return(result);
        }
        internal void WriteTransactionID(Guid GlobalTID, string localTID)
        {
            uint method = 0x51a;

            this.TrEntry(method, new object[] { GlobalTID, localTID });
            string str  = "[" + NmqiTools.ArrayToHexString(GlobalTID.ToByteArray()) + "]";
            string str2 = "[" + localTID + "]";

            lock (this.mutex)
            {
                writer_.WriteLine(this.GetHeader() + "Global Transaction ID: " + str);
                writer_.WriteLine(this.GetHeader() + "Local Transaction ID: " + str2);
            }
            base.TrExit(method);
        }
Esempio n. 15
0
 public MQCBD()
 {
     base.TrConstructor("%Z% %W% %I% %E% %U%");
     this.mqcbd                  = new MQBase.structMQCBD();
     this.mqcbd.strucId          = new byte[] { 0x43, 0x42, 0x44, 0x20 };
     this.mqcbd.version          = 1;
     this.mqcbd.callbackType     = 1;
     this.mqcbd.options          = 0;
     this.mqcbd.callbackArea     = IntPtr.Zero;
     this.mqcbd.callbackFunction = IntPtr.Zero;
     this.mqConsumer             = null;
     this.mqcbd.callbackName     = new byte[0x80];
     this.mqcbd.maxMsgLength     = -1;
     this.cbdId                  = NmqiTools.GetCurrentTimeInMs().ToString() + this.GetHashCode();
 }
Esempio n. 16
0
        internal void LogCurrentTransactionStart(byte[] xidBytes, MQXid xid, Guid queueManagerUid, int rmid, byte[] recinfo)
        {
            uint method = 0x52b;

            this.TrEntry(method, new object[] { xidBytes, queueManagerUid, rmid, recinfo });
            try
            {
                MQMessage mqMsg = new MQMessage();
                mqMsg.Persistence = 1;
                int     compCode = 0;
                int     reason   = 0;
                sbyte[] dst      = new sbyte[queueManagerUid.ToByteArray().Length];
                Buffer.BlockCopy(queueManagerUid.ToByteArray(), 0, dst, 0, dst.Length);
                base.TrText(method, "Qmid=" + NmqiTools.ArrayToHexString(queueManagerUid.ToByteArray()));
                sbyte[] numArray2 = new sbyte[recinfo.Length];
                Buffer.BlockCopy(recinfo, 0, numArray2, 0, numArray2.Length);
                base.TrText(method, "recordinfo=" + NmqiTools.ArrayToHexString(recinfo));
                sbyte[] numArray3 = new sbyte[xidBytes.Length];
                Buffer.BlockCopy(xidBytes, 0, numArray3, 0, numArray3.Length);
                base.TrText(method, "recordinfo=" + NmqiTools.ArrayToHexString(xidBytes));
                mqMsg.SetBytesProperty("dnet.XARECOVERY_QMID", dst);
                mqMsg.SetBytesProperty("dnet.XARECOVERY_RECINFO", numArray2);
                mqMsg.SetBytesProperty("dnet.XARECOVERY_XID", numArray3);
                mqMsg.SetIntProperty("dnet.XARECOVERY_RMID", rmid);
                mqMsg.SetDoubleProperty("dnet.XARECOVERY_TTIMEOUT", TransactionManager.MaximumTimeout.TotalMilliseconds);
                mqMsg.SetStringProperty("dnet.XARECOVERY_HOSTANDUSER", this.hostAndUser);
                this.marshal = new MQMarshalMessageForPut(mqMsg);
                mqMsg        = this.marshal.ConstructMessageForSend();
                byte[] sBuff           = mqMsg.GetBuffer();
                MQMessageDescriptor md = mqMsg.md;
                this.recoveryHconn.Session.MQFap.MQPUT(this.recoveryHconn, this.recoveryHobj.HOBJ, ref md, ref this.recoveryPutPmo, sBuff.Length, sBuff, null, 1, out compCode, out reason);
                base.TrText(method, "MessageId-" + NmqiTools.ArrayToHexString(md.MsgId));
                if (compCode != 0)
                {
                    base.throwNewMQException(compCode, reason);
                }
                this.TransactionLogList.Add(xid, mqMsg.md);
                this.marshal.Dispose(false);
                this.marshal = null;
                mqMsg        = null;
                sBuff        = null;
            }
            finally
            {
                base.TrExit(method);
            }
        }
Esempio n. 17
0
        private void LoadInfo()
        {
            uint method = 0x630;

            this.TrEntry(method);
            try
            {
                if (this.info == null)
                {
                    this.info = NmqiTools.GetQueueManagerInfo(base.env, this.MQFap, this.hconn);
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
Esempio n. 18
0
        public void Add(string name, int[] value)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(NmqiTools.Left(name, this.width1));
            builder.Append(NmqiTools.Left(":", this.width2));
            builder.Append("(");
            for (int i = 0; i < value.Length; i++)
            {
                if (i > 0)
                {
                    builder.Append(',');
                }
                builder.Append(value[i]);
            }
            builder.Append(")");
            this.fields.Add(builder.ToString());
        }
Esempio n. 19
0
        public void SetPutDateTime(int year, int month, int day, int hour, int minute, int second, int millis)
        {
            uint method = 0x415;

            this.TrEntry(method, new object[] { year, month, day, hour, minute, second, millis });
            StringBuilder builder = new StringBuilder();

            builder.Append(NmqiTools.Fix(year, 4));
            builder.Append(NmqiTools.Fix(month, 2));
            builder.Append(NmqiTools.Fix(day, 2));
            this.PutDate = builder.ToString();
            builder      = new StringBuilder();
            builder.Append(NmqiTools.Fix(hour, 2));
            builder.Append(NmqiTools.Fix(minute, 2));
            builder.Append(NmqiTools.Fix(second, 2));
            builder.Append(NmqiTools.Fix(millis, 2));
            this.PutTime = builder.ToString();
            base.TrExit(method);
        }
Esempio n. 20
0
        internal void LogCurrentTransactionEnd(MQXid xid, int rmid)
        {
            uint method = 0x52c;

            this.TrEntry(method, new object[] { xid, rmid });
            MQMessageDescriptor msgDesc = new MQMessageDescriptor();

            msgDesc.Version = 2;
            try
            {
                if (this.TransactionLogList.ContainsKey(xid))
                {
                    MQMessageDescriptor descriptor2 = (MQMessageDescriptor)this.TransactionLogList[xid];
                    msgDesc.MsgId = descriptor2.MsgId;
                    base.TrText(method, "MessageId-" + NmqiTools.ArrayToHexString(msgDesc.MsgId));
                    int          dataLength   = 0;
                    int          bufferLength = 0x1000;
                    byte[]       buffer       = new byte[bufferLength];
                    int          compCode     = 0;
                    int          reason       = 0;
                    MQProxyQueue proxyQueue   = ((ManagedHobj)this.recoveryHobj.HOBJ).ProxyQueue;
                    if (proxyQueue != null)
                    {
                        proxyQueue.ProxyMQGET(msgDesc, this.recoveryGetGmo, bufferLength, buffer, ref dataLength, null, ref compCode, ref reason);
                    }
                    else
                    {
                        this.recoveryHconn.GetMQFAP.MQGET(this.recoveryHconn, this.recoveryHobj.HOBJ, msgDesc, this.recoveryGetGmo, bufferLength, buffer, out dataLength, out compCode, out reason);
                    }
                    if (compCode != 0)
                    {
                        base.throwNewMQException(compCode, reason);
                    }
                    this.TransactionLogList.Remove(xid);
                    buffer = null;
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
        public int MQRMIXAPrepare(byte[] recoveryInformation)
        {
            uint method = 0x512;

            this.TrEntry(method, new object[] { recoveryInformation });
            int num2 = 0;

            try
            {
                byte[] buffer = null;
                buffer = new byte[this.xid.GetRoundedLength()];
                this.xid.WriteStruct(buffer, 0);
                this.xid.TraceFields();
                base.TrText(method, "Hconn value = " + this.hconn.Value + " issuing xa_prepare");
                num2 = this.hconn.Session.MQFap.XA_Prepare(this.hconn, this.xid, this.hconn.Rmid, this.flags);
                if ((num2 != 0) && (num2 != 3))
                {
                    TransactionException innerException = new TransactionException(NmqiTools.GetTranslatedExceptionMessage(this.ToString(), 0x20008385, (uint)num2));
                    MQException          exception2     = new MQException(2, 0x893, innerException);
                    CommonServices.SetValidInserts();
                    CommonServices.ArithInsert1   = (uint)this.hconn.Rmid;
                    CommonServices.CommentInsert1 = "xa_prepare call has failed with return code = " + num2;
                    base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                    throw exception2;
                }
                if (num2 == 0)
                {
                    base.TrText(method, "Hconn value = " + this.hconn.Value + " issuing MQPUT for tx recovery.");
                    this.hconn.XARecoveryBridge.LogCurrentTransactionStart(buffer, this.xid, this.myGuid, this.hconn.Rmid, recoveryInformation);
                }
            }
            finally
            {
                base.TrExit(method);
            }
            return(num2);
        }
Esempio n. 22
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);
        }
        public void Commit(Enlistment enlistment)
        {
            uint method = 0x524;

            this.TrEntry(method, new object[] { enlistment });
            try
            {
                int num2 = 0;
                MQTransactionRecovery.log.WriteLog("Outcome of the transaction(as per DTC):", "Commit");
                int num3 = 0;
                num2 = 0;
                while (num2 < this.incompleteXids.Count)
                {
                    if (this.recoveryXid.Equals(this.incompleteXids[num2]))
                    {
                        if (MQTransactionRecovery.userMode)
                        {
                            num3 = this.HeuristicTransactionCompletion();
                        }
                        else
                        {
                            num3 = this.recoveryHconn.GetMQFAP.XA_Commit(this.recoveryHconn, this.recoveryXid, this.rmid_, 0);
                            MQTransactionRecovery.log.WriteLog("Transaction Commit was successful with Returncode:  " + num3);
                        }
                        if (num3 < 0)
                        {
                            TransactionException innerException = new TransactionException(NmqiTools.GetTranslatedExceptionMessage(this.ToString(), 0x20008385, (uint)num3));
                            MQException          exception2     = new MQException(2, 0x893, innerException);
                            throw exception2;
                        }
                        enlistment.Done();
                        this.success = true;
                        break;
                    }
                    num2++;
                }
                if (num2 == this.incompleteXids.Count)
                {
                    MQTransactionRecovery.log.WriteLog("This particular Tx is not listed as in-doubt with WMQ. Releasing it now.");
                    enlistment.Done();
                    this.success = true;
                }
            }
            catch (Exception exception3)
            {
                base.TrException(method, exception3);
                MQTransactionRecovery.log.WriteLog("Actual state of the Transaction:", "Unknown/Indoubt");
                throw exception3;
            }
            finally
            {
                base.TrExit(method);
            }
        }
Esempio n. 24
0
        public ManagedHconn BestHconn()
        {
            uint method = 0x4c2;

            this.TrEntry(method);
            ManagedHconn hconn = null;

            try
            {
                while (hconn == null)
                {
                    long num2 = 0L;
                    long num3 = 0L;
                    lock (this.reconnectMutex)
                    {
                        if (this.hconns.Count == 0)
                        {
                            try
                            {
                                Monitor.Wait(this.reconnectMutex, -1, true);
                            }
                            catch (ThreadInterruptedException exception)
                            {
                                base.TrException(method, exception, 1);
                            }
                        }
                        long currentTimeInMs = NmqiTools.GetCurrentTimeInMs();
                        for (int i = 0; i < this.hconns.Count; i++)
                        {
                            ManagedHconn rcnHconn = (ManagedHconn)this.hconns[i];
                            if (!rcnHconn.IsReconnectable)
                            {
                                base.TrText(method, "Hconn : " + rcnHconn.Value + " is not elgiblefor reconnection any longer..");
                                rcnHconn.SetReconnectionFailure(2, 0x7d9, null);
                                this.ReleaseHconn(rcnHconn);
                            }
                            else if (rcnHconn.ReconnectExpiry < currentTimeInMs)
                            {
                                base.TrText(method, "Hconn : " + rcnHconn.Value + " has reconnection time expired..");
                                rcnHconn.SetReconnectionFailure(2, 0x9fc, null);
                                this.ReleaseHconn(rcnHconn);
                            }
                            else
                            {
                                long num6 = currentTimeInMs - rcnHconn.NextReconnect;
                                if (num2 <= num6)
                                {
                                    num2  = num6;
                                    hconn = rcnHconn;
                                }
                                else if (num3 < -num6)
                                {
                                    num3 = -num6;
                                }
                            }
                        }
                    }
                    if (hconn == null)
                    {
                        try
                        {
                            base.TrText(method, "Reconnection thread sleeping now for until iteration");
                            Thread.Sleep(Convert.ToInt32(num3));
                            continue;
                        }
                        catch (ThreadInterruptedException)
                        {
                            continue;
                        }
                    }
                }
            }
            finally
            {
                base.TrExit(method);
            }
            return(hconn);
        }
Esempio n. 25
0
 public void Add(string name, sbyte[] value)
 {
     this.AddField("", "", name, NmqiTools.ArrayToHexString(value));
 }