Пример #1
0
        public static QueueManagerInfo GetQueueManagerInfo(NmqiEnvironment env, NmqiMQ mq, Hconn hconn)
        {
            QueueManagerInfo   info     = env.NewQueueManagerInfo();
            MQObjectDescriptor pObjDesc = env.NewMQOD();

            pObjDesc.ObjectType = 5;
            int   options   = 0x20;
            Phobj pHobj     = env.NewPhobj();
            int   pCompCode = 0;
            int   pReason   = 0;

            mq.MQOPEN(hconn, ref pObjDesc, options, pHobj, out pCompCode, out pReason);
            if (pReason == 0)
            {
                Hobj   hOBJ       = pHobj.HOBJ;
                int[]  pSelectors = new int[] { 0x1f, 0x20, 2, 0x7df, 0x7f0 };
                int[]  pIntAttrs  = new int[3];
                byte[] pCharAttrs = new byte[0x60];
                mq.MQINQ(hconn, hOBJ, pSelectors.Length, pSelectors, pIntAttrs.Length, pIntAttrs, pCharAttrs.Length, pCharAttrs, out pCompCode, out pReason);
                if (pReason == 0)
                {
                    info.CommandLevel = pIntAttrs[0];
                    info.Platform     = pIntAttrs[1];
                    info.Ccsid        = pIntAttrs[2];
                    Encoding dotnetEncoding = MQCcsidTable.GetDotnetEncoding(info.Ccsid);
                    info.Name = dotnetEncoding.GetString(pCharAttrs, 0, 0x30);
                    info.Uid  = dotnetEncoding.GetString(pCharAttrs, 0x30, 0x30);
                }
                else
                {
                    NmqiException exception = new NmqiException(env, 0x253a, null, pCompCode, pReason, null);
                    env.LastException = exception;
                    throw exception;
                }
                mq.MQCLOSE(hconn, pHobj, 0, out pCompCode, out pReason);
                return(info);
            }
            NmqiException exception2 = new NmqiException(env, 0x2525, null, pCompCode, pReason, null);

            env.LastException = exception2;
            throw exception2;
        }
Пример #2
0
 public Phobj(NmqiEnvironment env)
 {
     base.TrConstructor("%Z% %W% %I% %E% %U%", new object[] { env });
     this.hobj = new ManagedHobj(env, -1);
 }
Пример #3
0
        public static byte[] GetMessage(NmqiEnvironment env, NmqiSP sp, Hconn hconn, Hobj hobj, MQMessageDescriptor md, MQGetMessageOptions gmo, int expectedMsgLength, int maxMsgLength, byte[] buffer, int msgTooSmallForBufferCount, out int dataLength, out int compCode, out int reason)
        {
            int num  = 0x1000;
            int num2 = 10;
            int num3 = (expectedMsgLength < 0) ? num : expectedMsgLength;

            num3 = Math.Min(num3, maxMsgLength);
            if ((buffer == null) || (buffer.Length < num3))
            {
                buffer = new byte[num3];
            }
            int encoding = md.Encoding;
            int ccsid    = md.Ccsid;

            byte[] msgId            = md.MsgId;
            byte[] correlId         = md.CorrelId;
            int    options          = gmo.Options;
            bool   callExitOnLenErr = false;
            int    returnedLength   = 0;
            int    bufferLength     = 0;

            byte[] buffer4 = null;
            dataLength = 0;
            compCode   = 0;
            reason     = 0;
            int num10 = 1;

            while (num10 != 0)
            {
                int num12;
                switch (num10)
                {
                case 1:
                    bufferLength = Math.Min(buffer.Length, maxMsgLength);
                    sp.NmqiGetMessage(hconn, hobj, md, gmo, bufferLength, buffer, out dataLength, out compCode, out reason);
                    num12 = reason;
                    if (num12 > 0x7da)
                    {
                        break;
                    }
                    switch (num12)
                    {
                    case 0:
                        goto Label_0100;

                    case 0x7da:
                        goto Label_0108;
                    }
                    goto Label_01CC;

                case 2:
                {
                    byte[] source    = buffer;
                    byte[] structure = new byte[bufferLength];
                    IntPtr zero      = IntPtr.Zero;
                    Marshal.StructureToPtr(structure, zero, false);
                    Marshal.Copy(source, 0, zero, dataLength);
                    buffer = structure;
                    int availableLength = dataLength;
                    if (!sp.NmqiConvertMessage(hconn, hobj, encoding, ccsid, options, callExitOnLenErr, md, buffer, out dataLength, availableLength, bufferLength, out compCode, out reason, out returnedLength))
                    {
                        goto Label_0232;
                    }
                    num10 = 0;
                    continue;
                }

                default:
                {
                    continue;
                }
                }
                switch (num12)
                {
                case 0x820:
                {
                    msgTooSmallForBufferCount = 0;
                    if (dataLength >= maxMsgLength)
                    {
                        goto Label_019C;
                    }
                    if (bufferLength < dataLength)
                    {
                        bufferLength = Math.Min(dataLength, maxMsgLength);
                    }
                    else
                    {
                        bufferLength = Math.Min(bufferLength * 2, maxMsgLength);
                    }
                    buffer4     = new byte[bufferLength];
                    buffer      = buffer4;
                    md.Encoding = encoding;
                    md.Ccsid    = ccsid;
                    md.MsgId    = msgId;
                    md.CorrelId = correlId;
                    num10       = 1;
                    continue;
                }

                case 0x848:
                case 0x88e:
                {
                    msgTooSmallForBufferCount = 0;
                    if (dataLength < maxMsgLength)
                    {
                        bufferLength = Math.Min(dataLength * 2, maxMsgLength);
                        num10        = 2;
                    }
                    else
                    {
                        num10 = 0;
                    }
                    continue;
                }

                default:
                    goto Label_01CC;
                }
Label_0100:
                num10 = 0;
                continue;
Label_0108:
                maxMsgLength = dataLength;
                md.Encoding  = encoding;
                md.Ccsid     = ccsid;
                md.MsgId     = msgId;
                md.CorrelId  = correlId;
                num10        = 1;
                continue;
Label_019C:
                num10 = 0;
                continue;
Label_01CC:
                num10 = 0;
                continue;
Label_0232:
                switch (reason)
                {
                case 0:
                {
                    num10 = 0;
                    continue;
                }

                case 0x848:
                case 0x88e:
                {
                    if (dataLength < maxMsgLength)
                    {
                        bufferLength = Math.Min(bufferLength * 2, maxMsgLength);
                        num10        = 2;
                    }
                    else
                    {
                        num10 = 0;
                    }
                    continue;
                }
                }
                num10 = 0;
            }
            byte[] buffer7 = buffer;
            if ((compCode == 0) || (compCode == 1))
            {
                if ((bufferLength > (dataLength * 2)) && (bufferLength > num))
                {
                    msgTooSmallForBufferCount++;
                }
                else
                {
                    msgTooSmallForBufferCount = 0;
                }
                if (msgTooSmallForBufferCount > num2)
                {
                    buffer = null;
                    msgTooSmallForBufferCount = 0;
                }
            }
            return(buffer7);
        }
Пример #4
0
        public void Inquire(int[] selectors, int[] intAttrs, byte[] charAttrs)
        {
            uint method = 0xed;

            this.TrEntry(method, new object[] { selectors, intAttrs, charAttrs });
            Hobj hOBJ      = null;
            int  pCompCode = 0;
            int  pReason   = 0;

            try
            {
                int length;
                int num3;
                if ((selectors == null) || (selectors.Length == 0))
                {
                    base.throwNewMQException(2, 0x813);
                }
                if (this.objectType == 5)
                {
                    if ((this.qMgr == null) || !this.qMgr.IsConnected)
                    {
                        base.throwNewMQException(2, 0x7e2);
                    }
                    if (this.isClosed)
                    {
                        base.throwNewMQException(2, 0x7e3);
                    }
                    if (((this.handleInq == null) || (this.handleInq.HOBJ == null)) || (this.handleInq.HOBJ.Handle == 0))
                    {
                        this.handleInq = MQQueueManager.nmqiEnv.NewPhobj();
                        this.OpenForInquire();
                    }
                    hOBJ = this.handleInq.HOBJ;
                }
                if (this.objectType == 3)
                {
                    if ((this.qMgr == null) || !this.qMgr.IsConnected)
                    {
                        base.throwNewMQException(2, 0x7e2);
                    }
                    if (this.isClosed)
                    {
                        base.throwNewMQException(2, 0x7e3);
                    }
                    hOBJ = this.objectHandle.HOBJ;
                }
                if (this.objectType == 1)
                {
                    if (!this.IsOpen)
                    {
                        base.throwNewMQException(2, 0x7e3);
                    }
                    hOBJ = this.objectHandle.HOBJ;
                }
                if (this.objectType == 8)
                {
                    if (!this.IsOpen)
                    {
                        base.throwNewMQException(2, 0x7e3);
                    }
                    hOBJ = this.objectHandle.HOBJ;
                }
                if (intAttrs == null)
                {
                    length = 0;
                }
                else
                {
                    length = intAttrs.Length;
                }
                if (charAttrs == null)
                {
                    num3 = 0;
                }
                else
                {
                    num3 = charAttrs.Length;
                }
                this.qMgr.nmqiConnector.MQINQ(this.qMgr.hConn, hOBJ, selectors.Length, selectors, length, intAttrs, num3, charAttrs, out pCompCode, out pReason);
                if (pCompCode != 0)
                {
                    this.qMgr.CheckHConnHealth(pReason);
                    base.throwNewMQException(pCompCode, pReason);
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
Пример #5
0
        public void Set(int[] selectors, int[] intAttrs, byte[] charAttrs)
        {
            uint method = 0xec;

            this.TrEntry(method, new object[] { selectors, intAttrs, charAttrs });
            Hobj hOBJ           = null;
            int  selectorCount  = 0;
            int  intAttrCount   = 0;
            int  charAttrLength = 0;
            int  pCompCode      = 0;
            int  pReason        = 0;

            try
            {
                if ((selectors == null) || (selectors.Length == 0))
                {
                    base.throwNewMQException(2, 0x813);
                }
                if (5 == this.objectType)
                {
                    if (this.qMgr == null)
                    {
                        base.throwNewMQException(2, 0x7e2);
                    }
                    if (this.isClosed)
                    {
                        base.throwNewMQException(2, 0x7e3);
                    }
                    if (((this.handleSet == null) || (this.handleSet.HOBJ == null)) || (this.handleSet.HOBJ.Handle == 0))
                    {
                        this.handleSet = MQQueueManager.nmqiEnv.NewPhobj();
                        this.OpenForSet();
                    }
                    hOBJ = this.handleSet.HOBJ;
                }
                if (this.objectHandle == null)
                {
                    this.objectHandle = MQQueueManager.nmqiEnv.NewPhobj();
                }
                if (1 == this.objectType)
                {
                    if (!this.IsOpen)
                    {
                        base.throwNewMQException(2, 0x7e3);
                    }
                    hOBJ = this.objectHandle.HOBJ;
                }
                if (8 == this.objectType)
                {
                    if (!this.IsOpen)
                    {
                        base.throwNewMQException(2, 0x7e3);
                    }
                    hOBJ = this.objectHandle.HOBJ;
                }
                if (3 == this.objectType)
                {
                    if (!this.IsOpen)
                    {
                        base.throwNewMQException(2, 0x7e3);
                    }
                    hOBJ = this.objectHandle.HOBJ;
                }
                selectorCount = selectors.Length;
                if (intAttrs != null)
                {
                    intAttrCount = intAttrs.Length;
                }
                if (charAttrs != null)
                {
                    charAttrLength = charAttrs.Length;
                }
                this.qMgr.nmqiConnector.MQSET(this.qMgr.hConn, hOBJ, selectorCount, selectors, intAttrCount, intAttrs, charAttrLength, charAttrs, out pCompCode, out pReason);
                if (pCompCode != 0)
                {
                    this.qMgr.CheckHConnHealth(pReason);
                    base.throwNewMQException(pCompCode, pReason);
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
Пример #6
0
        public bool Reconnect(ManagedHconn remoteHconn)
        {
            uint method = 0x4c3;

            this.TrEntry(method, new object[] { remoteHconn });
            int compCode = 0;
            int reason   = 0;

            try
            {
                Phconn pHconn = base.env.NewPhconn();
                remoteHconn.UnsetStarted();
                remoteHconn.GlobalMessageIndex = 0;
                base.TrText(method, string.Concat(new object[] { "Hconn : ", remoteHconn.Value, " ReconnectionID : ", remoteHconn.ConnectionId }));
                remoteHconn.NmqiConnectionOptions.ReconnectionID = remoteHconn.ConnectionId;
                try
                {
                    remoteHconn.DriveEventsEH(0, 0x9f0);
                }
                catch (Exception exception)
                {
                    base.TrException(method, exception);
                }
                try
                {
                    if (remoteHconn.NmqiConnectionOptions.RemoteQmidAsString == null)
                    {
                        remoteHconn.NmqiConnectionOptions.RemoteQmidAsString = remoteHconn.Uid;
                    }
                    base.TrText(method, string.Concat(new object[] { "Hconn : ", remoteHconn.Value, " RemoteQmidAsString : ", remoteHconn.NmqiConnectionOptions.RemoteQmidAsString }));
                }
                catch (NmqiException exception2)
                {
                    base.TrException(method, exception2, 1);
                    remoteHconn.SetReconnectionFailure(2, 0x9f4, exception2);
                    return(false);
                }
                string name = null;
                try
                {
                    name = remoteHconn.OriginalQueueManagerName;
                    base.TrText(method, string.Concat(new object[] { "Hconn : ", remoteHconn.Value, " OriginalQueueManagerName : ", name }));
                }
                catch (NmqiException exception3)
                {
                    base.TrException(method, exception3, 2);
                }
                MQFAP getMQFAP = remoteHconn.GetMQFAP;
                try
                {
                    getMQFAP.NmqiConnect(name, remoteHconn.NmqiConnectionOptions, remoteHconn.ConnectionOptions, remoteHconn.Parent, pHconn, out compCode, out reason, remoteHconn);
                    base.TrText(method, string.Concat(new object[] { "NmqiConnect during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                    if (compCode != 0)
                    {
                        return(false);
                    }
                }
                catch (MQException exception4)
                {
                    base.TrException(method, exception4, 3);
                    if ((exception4.CompCode != 0) && (exception4.Reason == 0x9f2))
                    {
                        remoteHconn.SetReconnectionFailure(2, 0x9f2, null);
                    }
                    return(false);
                }
                catch (Exception exception5)
                {
                    base.TrException(method, exception5, 4);
                    return(false);
                }
                if (remoteHconn.InTransaction())
                {
                    remoteHconn.SetTransactionDoomed();
                }
                remoteHconn.UnSetQuiescing();
                foreach (ManagedHobj hobj in remoteHconn.Hobjs)
                {
                    if (hobj.ParentHsub == null)
                    {
                        Phobj manHobj              = base.env.NewPhobj();
                        MQObjectDescriptor mqod    = hobj.Mqod;
                        Hobj           hOBJ        = manHobj.HOBJ;
                        SpiOpenOptions spiOpenOpts = hobj.SpiOpenOpts;
                        base.TrText(method, "Reopening " + mqod.ObjectName);
                        base.TrText(method, "Original name " + hobj.OriginalObjectName);
                        getMQFAP.nmqiOpen(remoteHconn, ref mqod, ref spiOpenOpts, hobj.OpenOptions, ref manHobj, out compCode, out reason, hobj.SpiCall, hobj);
                        base.TrText(method, string.Concat(new object[] { "MQOPEN during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                        if (((reason == 0x825) || (reason == 0x827)) && !hobj.OriginalObjectName.Equals(mqod.ObjectName))
                        {
                            string objectName   = mqod.ObjectName;
                            string dynamicQName = mqod.DynamicQName;
                            compCode          = 0;
                            reason            = 0;
                            mqod.ObjectName   = hobj.OriginalObjectName;
                            mqod.DynamicQName = objectName;
                            getMQFAP.MQOPEN(remoteHconn, ref mqod, hobj.OpenOptions, manHobj, out compCode, out reason, hobj);
                            base.TrText(method, string.Concat(new object[] { "MQOPEN during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                            mqod.ObjectName   = objectName;
                            mqod.DynamicQName = dynamicQName;
                        }
                        if (reason != 0)
                        {
                            remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                            return(false);
                        }
                        if (hobj.IsCallbackRegistered)
                        {
                            int operationP = 0x100;
                            if (hobj.IsCallbackSuspended)
                            {
                                operationP |= 0x10000;
                            }
                            MQCBD callbackDescriptor = hobj.CallbackDescriptor;
                            Hobj  hobjP = hobj;
                            MQMessageDescriptor callbackMessageDescriptor = hobj.CallbackMessageDescriptor;
                            MQGetMessageOptions callbackGetMessageOptions = hobj.CallbackGetMessageOptions;
                            getMQFAP.MQCB(remoteHconn, operationP, callbackDescriptor, hobjP, callbackMessageDescriptor, callbackGetMessageOptions, out compCode, out reason);
                            base.TrText(method, string.Concat(new object[] { "MQCB during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                            if (reason != 0)
                            {
                                remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                                return(false);
                            }
                        }
                    }
                }
                foreach (ManagedHsub hsub in remoteHconn.Hsbjs)
                {
                    int options = hsub.Mqsd.Options;
                    if ((options & 1) != 0)
                    {
                        options |= 2;
                    }
                    if ((options & 0x20) == 0)
                    {
                        options |= 0x400000;
                    }
                    if (((options & 8) != 0) && ((options & 6) != 0))
                    {
                        options |= 6;
                    }
                    hsub.Mqsd.Options = options;
                    Phobj pHsub = base.env.NewPhobj();
                    Phobj pHobj = base.env.NewPhobj();
                    if (hsub.Mqsd.SubExpiry != -1)
                    {
                        hsub.Mqsd.SubExpiry = hsub.GeExpiryRemainder();
                    }
                    getMQFAP.nmqiSubscribe(remoteHconn, hsub.Mqsd, ref pHobj, ref pHsub, out compCode, out reason, hsub.SpiSD, hsub.SpiCall, hsub);
                    base.TrText(method, string.Concat(new object[] { "MQSUB during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                    if (reason != 0)
                    {
                        if (!ManagedHconn.IsReconnectableReasonCode(reason) && (reason != 0x97d))
                        {
                            remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                        }
                        return(false);
                    }
                    ManagedHobj hobj3 = hsub.Hobj;
                    if (((hobj3 != null) && (hobj3.ProxyQueue != null)) && hobj3.IsCallbackRegistered)
                    {
                        int num6 = 0x100;
                        if (hobj3.IsCallbackSuspended)
                        {
                            num6 |= 0x10000;
                        }
                        MQCBD pCallbackDesc             = hobj3.CallbackDescriptor;
                        Hobj  hobj4                     = hobj3;
                        MQMessageDescriptor pMsgDescP   = hobj3.CallbackMessageDescriptor;
                        MQGetMessageOptions getMsgOptsP = hobj3.CallbackGetMessageOptions;
                        getMQFAP.MQCB(remoteHconn, num6, pCallbackDesc, hobj4, pMsgDescP, getMsgOptsP, out compCode, out reason);
                        base.TrText(method, string.Concat(new object[] { "MQCB during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                        if (reason != 0)
                        {
                            remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                            return(false);
                        }
                    }
                }
                if (remoteHconn.IsEventRegistered)
                {
                    int num7 = 0x100;
                    if (remoteHconn.IsEventSuspended)
                    {
                        num7 |= 0x10000;
                    }
                    getMQFAP.MQCB(remoteHconn, num7, remoteHconn.GetEventDescriptor(), base.env.NewPhobj().HOBJ, null, null, out compCode, out reason);
                    base.TrText(method, string.Concat(new object[] { "MQCB during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                    if (reason != 0)
                    {
                        if (!ManagedHconn.IsReconnectableReasonCode(reason))
                        {
                            remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                        }
                        return(false);
                    }
                }
                if (remoteHconn.IsCallbackStarted())
                {
                    MQCTLO pControlOpts = base.env.NewMQCTLO();
                    getMQFAP.MQCTL(remoteHconn, 1, pControlOpts, out compCode, out reason);
                    base.TrText(method, string.Concat(new object[] { "MQCTL during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                    if (reason != 0)
                    {
                        if (!ManagedHconn.IsReconnectableReasonCode(reason))
                        {
                            remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                        }
                        return(false);
                    }
                    if (remoteHconn.IsCallbackSuspended())
                    {
                        getMQFAP.MQCTL(remoteHconn, 0x10000, pControlOpts, out compCode, out reason);
                        if (reason != 0)
                        {
                            if (!ManagedHconn.IsReconnectableReasonCode(reason))
                            {
                                remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                            }
                            return(false);
                        }
                    }
                    remoteHconn.WakeDispatchThread();
                }
            }
            finally
            {
                base.TrExit(method, true, 11);
            }
            return(true);
        }