Ejemplo n.º 1
0
        private void RealOpen()
        {
            var od = new MQObjectDescriptor();

            od.ObjectType = MQC.MQOT_Q;
            od.ObjectName = ObjectName;
            base.Open(od);
        }
Ejemplo n.º 2
0
        private void OpenForPublication()
        {
            var od = new MQObjectDescriptor
            {
                ObjectType = MQC.MQOT_TOPIC,
                ObjectName = ObjectName,
                Version    = MQC.MQOD_VERSION_4
            };

            od.ObjectString.VSString = _topicName;
            base.Open(od);
        }
Ejemplo n.º 3
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.º 4
0
        protected void Open(MQObjectDescriptor od)
        {
            int hobj, compCode, reason;

            od.CopyCHARVIntoOD();

            if (od.Version == MQC.MQOD_VERSION_1 || od.Version == MQC.MQOD_VERSION_2)
            {
                MQOD structMQOD = od.StructMQOD;
                Bindings.MQOPEN(qMgr.Handle, ref structMQOD, OpenOptions, out hobj, 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.MQOPEN(qMgr.Handle, intPtr, OpenOptions, out hobj, out compCode, out reason);
                }
                finally
                {
                    if (intPtr != IntPtr.Zero)
                    {
                        Marshal.FreeCoTaskMem(intPtr);
                    }
                }
            }

            if (compCode != MQC.MQCC_OK)
            {
                throw new MQException(compCode, reason);
            }
            objectHandle = hobj;
            ObjectName   = od.ObjectName;
            ObjectType   = od.ObjectType;
        }