예제 #1
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);
            }
        }
예제 #2
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);
        }
예제 #3
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();
 }
예제 #4
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);
        }