public void Subscribe(MQSubscriptionDescriptor subscriptionDescriptor, int subqueueHandle = MQC.MQHO_NONE) { int compCode, reason; byte[] array = new byte[subscriptionDescriptor.GetRequiredBufferSize()]; subscriptionDescriptor.WriteStruct(array, 0); objectHandle = subqueueHandle; IntPtr intPtr = Marshal.AllocCoTaskMem(array.Length); try { Marshal.Copy(array, 0, intPtr, array.Length); Bindings.MQSUB(qMgr.Handle, intPtr, ref objectHandle, out subscriptionHandle, out compCode, out reason); } finally { if (intPtr != IntPtr.Zero) { Marshal.FreeCoTaskMem(intPtr); } } if (compCode != MQC.MQCC_OK) { throw new MQException(compCode, reason); } _subQueue = new MQQueue(qMgr); _subQueue.objectHandle = objectHandle; }
public void Subscribe(string subscriptionName, int subscriptionOptions, string topicName, string topicObject = "", string alternateUserId = null, int subqueueHandle = MQC.MQHO_NONE) { var descriptor = new MQSubscriptionDescriptor(); if (!string.IsNullOrEmpty(alternateUserId)) { descriptor.AlternateUserId = alternateUserId; } descriptor.ObjectName = topicObject; descriptor.ObjectString.VSString = topicName; descriptor.SubName.VSString = subscriptionName; descriptor.Options = subscriptionOptions; Subscribe(descriptor, subqueueHandle); }