Ejemplo n.º 1
0
        public void Get(MQMessage message, MQGetMessageOptions gmo)
        {
            int dataLength, compCode, reason;

            if (message == null)
            {
                throw new MQException(MQC.MQCC_FAILED, MQC.MQRC_MD_ERROR);
            }
            if (gmo == null)
            {
                throw new MQException(MQC.MQCC_FAILED, MQC.MQRC_GMO_ERROR);
            }
            message.ClearMessage();
            var maxMsgSize  = defaultMaxMsgSize;
            var structMQMD  = message.md.StructMQMD;
            var structMQGMO = gmo.StructMQGMO;
            var buffer      = new byte[maxMsgSize];

            Bindings.MQGET(qMgr.Handle, objectHandle, ref structMQMD, ref structMQGMO, maxMsgSize, buffer, out dataLength, out compCode, out reason);
            while (compCode != MQC.MQCC_OK && reason == MQC.MQRC_TRUNCATED_MSG_FAILED)
            {
                maxMsgSize = dataLength;
                buffer     = new byte[maxMsgSize];
                Bindings.MQGET(qMgr.Handle, objectHandle, ref structMQMD, ref structMQGMO, maxMsgSize, buffer, out dataLength, out compCode, out reason);
            }
            if (compCode != MQC.MQCC_OK)
            {
                throw new MQException(compCode, reason);
            }
            if (dataLength > 0)
            {
                message.Write(buffer, 0, (dataLength < maxMsgSize) ? dataLength : maxMsgSize);
                message.Seek(0);
            }
        }
Ejemplo n.º 2
0
        public void Put1(MQObjectDescriptor od, MQMessage message, MQPutMessageOptions pmo)
        {
            int compCode, reason;

            if (message == null)
            {
                throw new MQException(MQC.MQCC_FAILED, MQC.MQRC_MD_ERROR);
            }
            if (pmo == null)
            {
                throw new MQException(MQC.MQCC_FAILED, MQC.MQRC_PMO_ERROR);
            }

            od.CopyCHARVIntoOD();
            pmo.ValidateOptions();
            byte[] buffer      = message.GetBuffer();
            var    structMQMD  = message.md.StructMQMD;
            var    structMQPMO = pmo.StructMQPMO;

            if (od.Version == MQC.MQOD_VERSION_1 || od.Version == MQC.MQOD_VERSION_2)
            {
                var structMQOD = od.StructMQOD;
                Bindings.MQPUT1(objectHandle, ref structMQOD, ref structMQMD, ref structMQPMO, buffer.Length, buffer, out compCode, out reason);
            }
            else
            {
                byte[] array = new byte[od.GetRequiredBufferSize()];
                od.WriteStruct(array, 0);
                IntPtr intPtr = Marshal.AllocCoTaskMem(array.Length);
                try
                {
                    Marshal.Copy(array, 0, intPtr, array.Length);
                    Bindings.MQPUT1(objectHandle, intPtr, ref structMQMD, ref structMQPMO, buffer.Length, buffer, out compCode, out reason);
                }
                finally
                {
                    if (intPtr != IntPtr.Zero)
                    {
                        Marshal.FreeCoTaskMem(intPtr);
                    }
                }
            }
            if (compCode != MQC.MQCC_OK)
            {
                throw new MQException(compCode, reason);
            }
        }
Ejemplo n.º 3
0
        public void Publish(MQMessage message, MQPutMessageOptions pmo)
        {
            int compCode, reason;

            if (message == null)
            {
                throw new MQException(MQC.MQCC_FAILED, MQC.MQRC_MD_ERROR);
            }
            if (pmo == null)
            {
                throw new MQException(MQC.MQCC_FAILED, MQC.MQRC_PMO_ERROR);
            }
            pmo.ValidateOptions();
            byte[] buffer      = message.GetBuffer();
            var    structMQMD  = message.md.StructMQMD;
            var    structMQPMO = pmo.StructMQPMO;

            Bindings.MQPUT(qMgr.Handle, objectHandle, ref structMQMD, ref structMQPMO, buffer.Length, buffer, out compCode, out reason);
            if (compCode != MQC.MQCC_OK)
            {
                throw new MQException(compCode, reason);
            }
        }
Ejemplo n.º 4
0
 protected MQMessage(MQMessage msg)
 {
     this.ClearMessage();
     this.md = new MQMessageDescriptor(msg.md);
 }
Ejemplo n.º 5
0
 public void Get(MQMessage message, MQGetMessageOptions gmo) => _subQueue.Get(message, gmo);