Author |
Message
|
BOBD |
Posted: Fri Oct 01, 2004 12:20 pm Post subject: C# MQObjectDescriptor |
|
|
Novice
Joined: 01 Oct 2004 Posts: 12
|
Hello,
I am writing program using C# libraries. We are connecting to remote queue that mapped to mainframe queue. According to our vendor in order to connect to queue we need to set some fields on ObjectDescriptor(object name and ObjectQMgrName )
Using object browser I found class MQObjectDescriptor but I couldn’t find any interface on queue manager class where I can set it.
Can some one tell me how can I use this MQObjectDescriptor or any tips how to set objectname and ObjectQMgrName.
Thanks in advance.
Bob |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Oct 02, 2004 9:04 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
The queue name and qmanager name are string objects to be set on the ObjectDescriptor, before you open the queue.
Remember you have to have a handle on the qmgr to open a queue. Now if the qmgr specified in the ObjectDescriptor is not the same as the one in the handle, make sure that the one in the handle has a default way of routing messages to the qmgr in the ObjectDescriptor, otherwise the messages you put to the queue will land on the DLQ.
Enjoy  |
|
Back to top |
|
 |
BOBD |
Posted: Sun Oct 03, 2004 6:37 am Post subject: |
|
|
Novice
Joined: 01 Oct 2004 Posts: 12
|
Remote queue is configured correctly. I couldn’t find a way in .Net libraries to specify objectdescriptor. There is class MQObjectDescriptor but I couldn’t find ay interface where I can pass or set objectdescriptor. |
|
Back to top |
|
 |
jefflowrey |
Posted: Sun Oct 03, 2004 9:26 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
In order to connect to a queue in .NET, you need to first connect to a queue manager and get a QueueManager object.
Then you call the AccessQueue method on the Queue Manager object. Or you can create a new MQQueue object, using it's constructor.
If you need to specify information, like a queue manager name, there are versions of the AccessQueue method that will allow you to include that information in the Object Descriptor that ends up getting passed to the queue when you open it.
However, I really suspect that this is not what your Vendor is trying to tell you to do.
I suspect that they are trying to instruct you to set the ReplyToQueue and ReplyToQueueManager properties of your MQMessage objects.
The .NET API is fully documented in a pdf file called csqzav01.pdf that will be located on your Windows queue manager (if you installed the samples) at the root of the installation directory. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
BOBD |
Posted: Sun Oct 03, 2004 6:07 pm Post subject: |
|
|
Novice
Joined: 01 Oct 2004 Posts: 12
|
I am using C# and AccessQueue method doesn’t have Object Descriptor parameter. I can successfully get QueueMannager object but when I call AccessQueue I am getting error that queue doesn’t exists. The way vendor explained me I am connecting to queue manager that has foreign queue set up ( it is not local queue on their queue managwe) .I need to specify remote queue as part of object descriptor (object name and queuename). They are using object descriptor to get remote queue name and program name.
You are right that .NET classes fully documented the only problem is that I can’t find where I can specify objectdescriptor. There is no version of AccessQueue method that takes objectdescriptor as parameter. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Oct 03, 2004 7:37 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
From the .NET manual:
Quote: |
The MQMessage class encapsulates the data buffer that contains the actual message data, together with all the MQMD (message descriptor) parameters that describe that message. To build a new message, create a new instance of the MQMessage class and use the WriteXXX methods to put data into the message buffer. When the new message instance is created, all the MQMD parameters are automatically set to their default values, as defined in the WebSphere MQ Application Programming Reference. The Put() method of MQQueue also takes an instance of the MQPutMessageOptions class as a parameter. This class represents the MQPMO structure. The following example creates a message and puts it onto a queue: |
Quote: |
To access queues, use the MQQueueManager class. The MQOD (object descriptor structure) is collapsed into the parameters of these methods. For example, to open a queue on a queue manager called queueManager, use the following code:
MQQueue queue = queueManager.AccessQueue("qName", MQC.MQOO_OUTPUT, "qMgrName", "dynamicQName", "altUserId");
The options parameter is the same as the Options parameter in the MQOPEN call. The AccessQueue method returns a new object of class MQQueue. When you have finished using the queue, use the Close() method to close it, as in the following example: queue.Close();
|
Enjoy  |
|
Back to top |
|
 |
JasonE |
Posted: Mon Oct 04, 2004 1:42 am Post subject: |
|
|
Grand Master
Joined: 03 Nov 2003 Posts: 1220 Location: Hursley
|
As per the above update, you need to stop thinking in terms of the C interface, where you would manually specify an object descriptor, and start thinking in terms of the supplied OO interface. Yes, there is an internal class for object descriptor, but it is created and populated when the MQQueue is constructed via the various classes. |
|
Back to top |
|
 |
BOBD |
Posted: Mon Oct 04, 2004 9:35 am Post subject: |
|
|
Novice
Joined: 01 Oct 2004 Posts: 12
|
I need to be able to overwrite default values of the MQObjectDescriptor. the manual says that structure is collapsed into parameters in AccessQueue methods but there are only two versions of the method
Public Function AccessQueue(ByVal queueName As String, ByVal openOptions As Integer) As IBM.WMQ.MQQueue
Public Function AccessQueue(ByVal queueName As String, ByVal openOptions As Integer, ByVal queueManagerName As String, ByVal dynamicQueueName As String, ByVal alternateUserId As String) As IBM.WMQ.MQQueue
None of these methods have all fields of the MQObjectDescriptor.
MQObjectDescriptor is public class and not internal.
If you know how to modify default object descriptor I would really appreciate some code sample.
Thanks in advance for all your help.
Bob |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Oct 04, 2004 9:44 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
According to your original message, you only need to override TWO fields of the ObjectDescriptor - the queue manager name and the queue name.
Those fields you can specify using AccessQueue.
If you need to override OTHER fields in the ObjectDescriptor, you may need to use something other than .NET - and you certainly need to provide a much clearer explanation of your requirements if you want help.
And again, I suspect that you are barking up the wrong tree, and you do not need to change the Object Descriptor any more than you have. Are you connecting to the mainframe queue manager directly, or to an intermediate queue manager? You said "a remote queue mapped to a mainframe queue", so I would assume that you are connecting to an intermediate queue manager. If that is the case, then I suspect you are trying to perform a request/reply pattern, and thus you actually need to specify a ReplyToQueue and ReplyToQueueManager - which are properties of the MQMessage object, not the ObjectDescriptor when opening a queue. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
BOBD |
Posted: Mon Oct 04, 2004 5:48 pm Post subject: |
|
|
Novice
Joined: 01 Oct 2004 Posts: 12
|
I would like to thank everybody who participated in this thread.
I spoke with vendor as well as IBM support. They are using request/reply pattern, but instead of defining remote queue they use local queue with message broker. Message broker reads object descriptor and forward message to specific queue. This is not the best solution because they introduce additional dependencies (we have to know mainframe queuemanger and queue name)
Better solution would be to set up remote queue definition on their site.
There is no direct access to MQOD or MD structures in . NET. When you are calling AccessQueue or MQQueue constructor it partially populates MQOD the same applies to QMD(populated when you create message object).
Message object descriptor is internal structure. In order to set custom values you need to create specialized version of message (inherit from MQMessage). In this case it can be easily modified.
I started to look into object library structure and it is possible to modify I just didn’t spend enough time.
My solution was simple. Instead of using AccessQueue method use MQQueue constructor where parameters are :
public MQQueue(MQQueueManager qMgr, String queueName, int openOptions, String queueManagerName, String dynamicQueueName, String alternateUserId )
Thanks, Bob |
|
Back to top |
|
 |
|