Exemple #1
0
        internal void StartConversation()
        {
            uint method = 0x621;

            this.TrEntry(method);
            MQSOCKACT mqsockact   = new MQSOCKACT();
            int       translength = 0x1c + mqsockact.GetLength();
            bool      flag        = CommonServices.TraceEnabled();
            MQTSH     rTSH        = null;

            try
            {
                MQTSH tsh = this.AllocateTSH(2, 12, 0, true, translength);
                mqsockact.Type           = 1;
                mqsockact.ConversationID = this.conversationId;
                mqsockact.RequestID      = 0;
                mqsockact.Parm1          = Thread.CurrentThread.ManagedThreadId;
                mqsockact.Parm2          = this.traceIdentifier;
                tsh.Offset = tsh.WriteStruct(tsh.TshBuffer, tsh.Offset);
                tsh.Offset = mqsockact.WriteStruct(tsh.TshBuffer, tsh.Offset);
                tsh.Offset = 0;
                if (flag)
                {
                    base.TrAPI(method, "__________");
                    base.TrAPI(method, "START CONVERSATION FLOW >>");
                    base.TrData(method, 0, "Conversation Id", BitConverter.GetBytes(this.ConversationId));
                    base.TrData(method, 0, "Buffer", tsh.Offset, tsh.Length, tsh.TshBuffer);
                    base.TrAPIOutput(method, "CompCode");
                    base.TrAPIOutput(method, "Reason");
                }
                try
                {
                    try
                    {
                        this.parentConnection.RequestSendLock();
                        this.Connection.SendTSH(tsh);
                    }
                    finally
                    {
                        this.parentConnection.ReleaseSendLock();
                    }
                    rTSH = this.ReceiveTSH(null);
                    if ((rTSH.ControlFlags1 & 8) != 0)
                    {
                        NmqiException exception = new NmqiException(base.env, -1, null, 2, 0x80b, null);
                        base.TrException(method, exception);
                        throw exception;
                    }
                    switch (rTSH.SegmentType)
                    {
                    case 5:
                        if ((rTSH.ControlFlags1 & 2) != 0)
                        {
                            NmqiException exception2 = new NmqiException(base.env, -1, null, 2, 0x8e1, null);
                            base.TrException(method, exception2);
                            throw exception2;
                        }
                        return;

                    case 12:
                        mqsockact.ReadStruct(rTSH.TshBuffer, rTSH.Offset);
                        return;
                    }
                    CommonServices.SetValidInserts();
                    CommonServices.ArithInsert1   = (uint)this.conversationId;
                    CommonServices.ArithInsert2   = (uint)mqsockact.Type;
                    CommonServices.CommentInsert1 = "Start Conversation Request has been refused by QMgr";
                    CommonServices.CommentInsert2 = "Unknown SockACT from server for START_CONV";
                    base.FFST("%Z% %W% %I% %E% %U%", "%C%", method, 1, 0x8e1, 0);
                    NmqiException ex = new NmqiException(base.env, -1, null, 2, 0x8e1, null);
                    base.TrException(method, ex);
                    throw ex;
                }
                finally
                {
                    if (flag)
                    {
                        base.TrAPI(method, "__________");
                        base.TrAPI(method, "START CONVERSATION FLOW <<");
                        base.TrData(method, 0, "Name", BitConverter.GetBytes(this.ConversationId));
                    }
                    this.ReleaseReceivedTSH(rTSH);
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
Exemple #2
0
        public void Run()
        {
            uint method = 0x60e;

            this.TrEntry(method);
            this.threadId = Thread.CurrentThread.GetHashCode();
            string str = "RcvThread: " + this.remoteConnection.ToString();

            Thread.CurrentThread.Name = str;
            try
            {
                int       conversationID;
                int       requestID;
                MQSession sessionByConvId;
                int       segmentType;
                MQSOCKACT mqsockact;
                MQTSH     rTSH = null;
Label_0040:
                rTSH = this.ReceiveOneTSH();
                if (rTSH == null)
                {
                    base.TrText(method, "Null TSH is received.. breaking and disconnecting now");
                    return;
                }
                if (this.remoteConnection.RemoteEncoding != rTSH.Encoding)
                {
                    this.remoteConnection.RemoteEncoding = rTSH.Encoding;
                }
                switch (rTSH.TSHType)
                {
                case 1:
                    base.TrText(method, "TSHM data has been received");
                    conversationID = rTSH.ConversationID;
                    requestID      = rTSH.RequestID;
                    base.TrText(method, "ConversationId = " + conversationID);
                    base.TrText(method, "RequestId = " + requestID);
                    sessionByConvId = this.remoteConnection.GetSessionByConvId(conversationID);
                    if ((sessionByConvId == null) || !sessionByConvId.IsEndRequested)
                    {
                        break;
                    }
                    base.TrText(method, "Current Sessions " + sessionByConvId.ToString() + " ending..");
                    goto Label_0040;

                case 2:
                {
                    if (rTSH.SegmentType != 12)
                    {
                        goto Label_0515;
                    }
                    mqsockact = new MQSOCKACT();
                    if ((rTSH.Encoding & 15) == 2)
                    {
                        goto Label_037D;
                    }
                    base.TrText(method, "We received BigEndian data, read it into our encoding");
                    byte[] dst = new byte[mqsockact.GetLength()];
                    Buffer.BlockCopy(rTSH.TshBuffer, rTSH.Offset, dst, 0, mqsockact.GetLength());
                    Array.Reverse(dst);
                    mqsockact.ReadStruct(dst, 0);
                    goto Label_0391;
                }

                default:
                {
                    CommonServices.SetValidInserts();
                    CommonServices.ArithInsert1   = 1;
                    CommonServices.CommentInsert1 = this.remoteConnection.NegotiatedChannel.ChannelName;
                    CommonServices.CommentInsert2 = "Invalid TSH flow is received on the receiver thread";
                    base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                    NmqiException exception7 = new NmqiException(base.env, -1, null, 2, 0x7d9, null);
                    base.TrException(method, exception7);
                    throw exception7;
                }
                }
                if (requestID == 0)
                {
                    if (sessionByConvId != null)
                    {
                        sessionByConvId.DeliverTSH(rTSH);
                    }
                    else if (conversationID == 1)
                    {
                        this.remoteConnection.DeliverTSH(rTSH);
                    }
                    else
                    {
                        base.TrText(method, "Unknown Conversation & RequestId");
                    }
                }
                else
                {
                    if (requestID != 1)
                    {
                        goto Label_0285;
                    }
                    if (sessionByConvId == null)
                    {
                        base.TrText(method, "Unknown Conversation and no existing Session could be found for it.");
                    }
                    else
                    {
                        MQProxyQueueManager proxyQueueManager;
                        rTSH        = sessionByConvId.ProcessReceivedData(rTSH);
                        segmentType = rTSH.SegmentType;
                        switch (segmentType)
                        {
                        case 13:
                        case 15:
                            proxyQueueManager = sessionByConvId.Hconn.ProxyQueueManager;
                            if (proxyQueueManager == null)
                            {
                                NmqiException exception = new NmqiException(base.env, -1, null, 2, 0x7d9, null);
                                CommonServices.SetValidInserts();
                                CommonServices.ArithInsert1   = 1;
                                CommonServices.ArithInsert2   = (uint)segmentType;
                                CommonServices.CommentInsert1 = "PQM couldn't be found on obtained Session for TSH flow";
                                base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                                throw exception;
                            }
                            break;

                        default:
                            goto Label_0237;
                        }
                        switch (segmentType)
                        {
                        case 13:
                            proxyQueueManager.AddMessage(rTSH);
                            break;

                        case 15:
                            proxyQueueManager.ReceiveNotification(rTSH);
                            break;
                        }
                        sessionByConvId.ReleaseReceivedTSH(rTSH);
                    }
                }
                goto Label_0040;
Label_0237:
                CommonServices.SetValidInserts();
                CommonServices.ArithInsert1   = 1;
                CommonServices.ArithInsert2   = (uint)segmentType;
                CommonServices.CommentInsert1 = "Incorrect Segment type received on multiplexing flow";
                base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                NmqiException exception2 = new NmqiException(base.env, -1, null, 2, 0x7d9, null);
                throw exception2;
Label_0285:
                if ((requestID % 2) != 0)
                {
                    if (sessionByConvId == null)
                    {
                        base.TrText(method, "Unknown Conversation and no existing Session could be found for it.");
                    }
                    else
                    {
                        sessionByConvId.DeliverExchangeReply(requestID, rTSH);
                    }
                    goto Label_0040;
                }
                NmqiException ex = new NmqiException(base.env, -1, null, 2, 0x893, null);
                CommonServices.SetValidInserts();
                CommonServices.ArithInsert1   = 1;
                CommonServices.CommentInsert1 = this.remoteConnection.NegotiatedChannel.ChannelName;
                CommonServices.CommentInsert2 = "Unknown request id flow on the multiplexed connection";
                base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                base.TrException(method, ex);
                throw ex;
Label_037D:
                mqsockact.ReadStruct(rTSH.TshBuffer, rTSH.Offset);
Label_0391:
                switch (mqsockact.Type)
                {
                case 1:
                case 4:
                case 5:
                case 6:
                    goto Label_0040;

                case 2:
                {
                    bool informQmgr = false;
                    if ((rTSH.ControlFlags1 & 1) != 0)
                    {
                        base.TrText(method, "rfpSAT_END_CONV request with rfpTCF_CONFIRM_REQUEST received");
                        informQmgr = true;
                    }
                    int       convId   = mqsockact.ConversationID;
                    MQSession session2 = this.remoteConnection.GetSessionByConvId(convId);
                    if (session2 != null)
                    {
                        this.remoteConnection.RemoveSession(session2.ConversationId, informQmgr);
                        NmqiException exception4 = new NmqiException(base.env, -1, null, 2, 0x7d9, null);
                        base.TrException(method, exception4);
                        session2.AsyncFailureNotify(exception4);
                    }
                    else if (convId == 1)
                    {
                        NmqiException exception5 = new NmqiException(base.env, -1, null, 2, 0x7d9, null);
                        base.TrException(method, exception5);
                        this.remoteConnection.AsyncFailureNotify(exception5, false);
                    }
                    else
                    {
                        base.TrData(method, 1, "hConn not recognised by connection,ConversationID ", BitConverter.GetBytes(mqsockact.ConversationID));
                    }
                    goto Label_057D;
                }

                case 3:
                {
                    NmqiException exception6 = new NmqiException(base.env, -1, null, 2, 0x89a, null);
                    base.TrException(method, exception6);
                    this.remoteConnection.AsyncFailureNotify(exception6, true);
                    goto Label_0040;
                }

                case 7:
                    this.remoteConnection.QmQuiescing();
                    goto Label_057D;

                case 9:
                    switch (mqsockact.Parm1)
                    {
                    case 1:
                        goto Label_0507;
                    }
                    goto Label_057D;

                default:
                    goto Label_057D;
                }
                this.remoteConnection.NotifyReconnect(false);
                goto Label_057D;
Label_0507:
                this.remoteConnection.NotifyReconnect(true);
                goto Label_057D;
Label_0515:
                if ((rTSH.ControlFlags1 & 8) != 0)
                {
                    this.remoteConnection.AnalyseErrorSegment(rTSH);
                    goto Label_057D;
                }
                if (rTSH.SegmentType != 9)
                {
                    goto Label_0570;
                }
                if (this.remoteConnection.FapLevel >= 10)
                {
                    if ((rTSH.ControlFlags1 & 1) != 0)
                    {
                        goto Label_0562;
                    }
                    goto Label_0040;
                }
                if ((rTSH.ControlFlags1 & 1) != 0)
                {
                    goto Label_0040;
                }
Label_0562:
                this.remoteConnection.SendHeartbeat(2);
                goto Label_057D;
Label_0570:
                if (rTSH.SegmentType == 11)
                {
                    goto Label_0040;
                }
Label_057D:
                this.remoteConnection.ReleaseReceivedTSH(rTSH);
                goto Label_0040;
            }
            catch (Exception exception8)
            {
                base.TrException(method, exception8, 1);
                NmqiException e = null;
                if (exception8 is NmqiException)
                {
                    e = (NmqiException)exception8;
                }
                else if (exception8 is MQException)
                {
                    e = new NmqiException(base.env, -1, null, (exception8 as MQException).CompCode, (exception8 as MQException).Reason, null);
                }
                else
                {
                    int compCode = 2;
                    int reason   = 0x893;
                    CommonServices.SetValidInserts();
                    CommonServices.ArithInsert1   = 1;
                    CommonServices.CommentInsert1 = this.remoteConnection.NegotiatedChannel.ChannelName.Trim();
                    CommonServices.CommentInsert2 = "System Exception generated on Receiver thread - " + exception8.Message;
                    CommonServices.CommentInsert3 = "Exception Stack - " + exception8.StackTrace;
                    base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                    e = new NmqiException(base.env, -1, null, compCode, reason, exception8);
                }
                try
                {
                    if (this.remoteConnection != null)
                    {
                        this.remoteConnection.AsyncFailureNotify(e, false);
                    }
                }
                catch (NmqiException exception10)
                {
                    base.TrException(method, exception10, 2);
                }
                catch (Exception exception11)
                {
                    base.TrException(method, exception11, 3);
                    CommonServices.SetValidInserts();
                    CommonServices.ArithInsert1   = 1;
                    CommonServices.CommentInsert1 = this.remoteConnection.NegotiatedChannel.ChannelName;
                    CommonServices.CommentInsert2 = "System Exception generated on AsyncFailureNotify - " + exception11.Message;
                    CommonServices.CommentInsert3 = "Exception Stack - " + exception11.StackTrace;
                    base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                }
                if (!this.disconnecting)
                {
                    try
                    {
                        if (this.remoteConnection != null)
                        {
                            this.remoteConnection.Disconnect();
                        }
                    }
                    catch (NmqiException exception12)
                    {
                        base.TrException(method, exception12, 4);
                    }
                    catch (Exception exception13)
                    {
                        base.TrException(method, exception13, 5);
                        CommonServices.SetValidInserts();
                        CommonServices.ArithInsert1   = 1;
                        CommonServices.CommentInsert1 = this.remoteConnection.NegotiatedChannel.ChannelName;
                        CommonServices.CommentInsert2 = "System Exception generated while Disconnecting - " + exception13.Message;
                        CommonServices.CommentInsert3 = "Exception Stack - " + exception13.StackTrace;
                        base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                    }
                }
            }
            finally
            {
                if (this.commsBuffer != null)
                {
                    this.commsBuffer.Free();
                }
                base.TrExit(method);
            }
        }