Example #1
0
        protected void Open(ref MQObjectDescriptor od)
        {
            uint method = 0x75;

            this.TrEntry(method, new object[] { od });
            int pCompCode = 0;
            int pReason   = 0;

            try
            {
                od.CopyCHARVIntoOD();
                if (base.qMgr.CommandLevel < 700)
                {
                    int openOptions = base.OpenOptions;
                    if (base.objectHandle == null)
                    {
                        base.objectHandle = MQQueueManager.nmqiEnv.NewPhobj();
                    }
                    base.qMgr.nmqiConnector.MQOPEN(base.qMgr.hConn, ref od, openOptions, base.objectHandle, out pCompCode, out pReason);
                    base.hObj = base.objectHandle.HOBJ;
                }
                else
                {
                    SpiOpenOptions options = new SpiOpenOptions();
                    options.Options = base.OpenOptions;
                    NmqiSP nmqiConnector = (NmqiSP)base.qMgr.nmqiConnector;
                    if (base.objectHandle == null)
                    {
                        base.objectHandle = MQQueueManager.nmqiEnv.NewPhobj();
                    }
                    nmqiConnector.SpiOpen(base.qMgr.hConn, ref od, ref options, base.objectHandle, out pCompCode, out pReason);
                    base.hObj = base.objectHandle.HOBJ;
                    if (pCompCode != 2)
                    {
                        this.propControl = options.PropertyControl;
                    }
                }
                if (pCompCode != 0)
                {
                    base.qMgr.CheckHConnHealth(pReason);
                    base.throwNewMQException(pCompCode, pReason);
                }
                base.isClosed = false;
            }
            catch (MQException exception)
            {
                pCompCode = exception.CompCode;
                pReason   = exception.Reason;
                throw exception;
            }
            finally
            {
                base.unsafe_compCode = pCompCode;
                base.unsafe_reason   = pReason;
                base.TrExit(method);
            }
        }
Example #2
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);
        }
Example #3
0
        public void Get(MQMessage message, MQGetMessageOptions gmo, int maxMsgSize, int spigmo)
        {
            uint method = 550;

            this.TrEntry(method, new object[] { message, gmo, maxMsgSize, spigmo });
            int  num2       = 0;
            bool flag       = false;
            int  dataLength = 0;

            byte[] buffer   = null;
            int    compCode = 0;
            int    reason   = 0;

            try
            {
                NmqiSP nmqiConnector = (NmqiSP)base.qMgr.nmqiConnector;
                if (message == null)
                {
                    base.throwNewMQException(2, 0x7ea);
                }
                if (gmo == null)
                {
                    base.throwNewMQException(2, 0x88a);
                }
                if (maxMsgSize < 0)
                {
                    base.throwNewMQException(2, 0x7d5);
                }
                MQSPIGetOpts spigo        = new MQSPIGetOpts(spigmo);
                int          options      = gmo.Options;
                int          characterSet = message.CharacterSet;
                int          num7         = gmo.Options;
                if ((num7 & 0x8000000) != 0)
                {
                    gmo.Options &= -134217729;
                    gmo.Options |= 0x2000000;
                }
                else if ((((num7 & 0x10000000) == 0) && ((num7 & 0x2000000) == 0)) && ((num7 & 0x4000000) == 0))
                {
                    gmo.Options |= 0x2000000;
                }
                message.ClearMessage();
                num2 = gmo.Options;
                flag = true;
                if ((gmo.Options & 0x1006) == 0)
                {
                    gmo.Options |= 4;
                }
                if (maxMsgSize == 0)
                {
                    int         num8       = gmo.Options;
                    MQBase.MQMD targetMqmd = new MQBase.MQMD();
                    base.CopyMQMD(message.md.StructMQMD, ref targetMqmd);
                    maxMsgSize   = MQDestination.defaultMaxMsgSize;
                    buffer       = new byte[maxMsgSize];
                    gmo.Options &= -65;
                    nmqiConnector.SPIGet(base.qMgr.hConn, base.objectHandle.HOBJ, ref message.md, ref gmo, ref spigo, maxMsgSize, buffer, out dataLength, out compCode, out reason);
                    while ((1 == compCode) && (0x820 == reason))
                    {
                        gmo.Options = num8;
                        MQBase.MQMD structMQMD = message.md.StructMQMD;
                        base.CopyMQMD(targetMqmd, ref structMQMD);
                        message.md.StructMQMD = structMQMD;
                        maxMsgSize            = dataLength;
                        buffer       = new byte[maxMsgSize];
                        gmo.Options &= -65;
                        nmqiConnector.SPIGet(base.qMgr.hConn, base.objectHandle.HOBJ, ref message.md, ref gmo, ref spigo, maxMsgSize, buffer, out dataLength, out compCode, out reason);
                    }
                    gmo.Options = num8;
                }
                else
                {
                    buffer = new byte[maxMsgSize];
                    nmqiConnector.SPIGet(base.qMgr.hConn, base.objectHandle.HOBJ, ref message.md, ref gmo, ref spigo, maxMsgSize, buffer, out dataLength, out compCode, out reason);
                }
                if (compCode != 2)
                {
                    this.spiQueueEmpty   = spigo.QueueEmpty != 0;
                    message.spiInherited = spigo.Inherited != 0;
                    message.spiQTime     = spigo.QTime;
                }
                else
                {
                    this.spiQueueEmpty   = false;
                    message.spiInherited = false;
                    message.spiQTime     = 0L;
                }
                byte[] b = null;
                if (compCode != 2)
                {
                    if ((options & 0x2000000) == 0)
                    {
                        b = base.PerformMsgProcessingAfterGet(ref message, buffer, (dataLength > buffer.Length) ? buffer.Length : dataLength);
                    }
                    else
                    {
                        b = buffer;
                    }
                    dataLength = b.Length;
                }
                gmo.Options = options;
                message.totalMessageLength = dataLength;
                if (dataLength > 0)
                {
                    message.Write(b, 0, (dataLength < maxMsgSize) ? dataLength : maxMsgSize);
                    message.Seek(0);
                }
                if (compCode != 0)
                {
                    base.qMgr.CheckHConnHealth(reason);
                    base.throwNewMQException(compCode, reason);
                }
            }
            catch (MQException exception)
            {
                compCode = exception.CompCode;
                reason   = exception.Reason;
                throw exception;
            }
            finally
            {
                if (flag)
                {
                    gmo.Options = num2;
                }
                base.unsafe_compCode = compCode;
                base.unsafe_reason   = reason;
                base.TrExit(method);
            }
        }