Author |
Message
|
MQLuvin |
Posted: Thu Aug 26, 2010 2:37 am Post subject: How can I read ApplIdentityData using WebSphere .Net Classes |
|
|
Newbie
Joined: 26 Aug 2010 Posts: 5
|
Hi,
I need to update our existing codebase that references amqmdnet (i.e. not XMS or JMS) in order to send/receive messages. We have a new requirement to read the ApplIdentityData header property from a message, and I am struggling to achieve this.
I can see that the SetStringProperty and GetStringProperty methods have been added since I installed the V7 WebSphere MQ client. If I try to write a message to a queue using:
Code: |
MQMessage msg = new MQMessage();
...
msg.SetStringProperty("ApplIdentityData", "MyValue"); |
...this succeeds, but then when I later try to read it:
Code: |
msg.GetStringProperty("ApplIdentityData"); |
...I get an error of type MQException "MQRC_PROPERTY_NAME_ERROR" ReasonCode 2442.
In sample code I have found on various forums, it seems everyone is setting various properties on the connection factory or destination objects in order to allow writing properties in this way. But we are using an MQQueueManager object to connect which doesn't allow this.
I am new to MQ development as I'm sure you can tell, so any help would be greatly appreciated. Can we read the header information that another system is going to place into the ApplIdentityData property using the basic WebSphere .Net classes?
Thanks! |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Aug 26, 2010 5:28 am Post subject: Re: How can I read ApplIdentityData using WebSphere .Net Cla |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
MQLuvin wrote: |
Hi,
I need to update our existing codebase that references amqmdnet (i.e. not XMS or JMS) in order to send/receive messages. We have a new requirement to read the ApplIdentityData header property from a message, and I am struggling to achieve this.
I can see that the SetStringProperty and GetStringProperty methods have been added since I installed the V7 WebSphere MQ client. If I try to write a message to a queue using:
Code: |
MQMessage msg = new MQMessage();
...
msg.SetStringProperty("ApplIdentityData", "MyValue"); |
...this succeeds, but then when I later try to read it:
Code: |
msg.GetStringProperty("ApplIdentityData"); |
...I get an error of type MQException "MQRC_PROPERTY_NAME_ERROR" ReasonCode 2442.
In sample code I have found on various forums, it seems everyone is setting various properties on the connection factory or destination objects in order to allow writing properties in this way. But we are using an MQQueueManager object to connect which doesn't allow this.
I am new to MQ development as I'm sure you can tell, so any help would be greatly appreciated. Can we read the header information that another system is going to place into the ApplIdentityData property using the basic WebSphere .Net classes?
Thanks! |
AFAIK the ApplIdentityData is not a writable property in JMS (or XMS?). So your attempt to create one by writing to it might confuse the system while reading it. Try using MyApplIdendityData and let us know how you fare.
And by the way if you are not using XMS then the application information is not carried as a property but is carried on the MQMD. Lookup the programer's manual and reference.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
MQLuvin |
Posted: Thu Aug 26, 2010 5:39 am Post subject: |
|
|
Newbie
Joined: 26 Aug 2010 Posts: 5
|
Unfortunately I get an error calling GetStringProperty() whatever name I use as the property name. However, what is going to be happening on our client site is that a third party tool is going to send a message to the queue containing some data in the ApplIdentityData property. I will then be required to read this header information from the message (in the past we have just read the actual message data and ignored anything in the header) and process this.
If you are right in thinking this header property can't be written to then I will have serious problems in testing any code I produce
Does anyone have any code pertaining to the WebSphere MQ .Net classes (i.e. not using the XMS or JMS APIs) where they have successfully called SetStringProperty and then subsequently read that info back using GetStringProperty?
Thanks |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Aug 26, 2010 7:55 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
MQLuvin wrote: |
Unfortunately I get an error calling GetStringProperty() whatever name I use as the property name. However, what is going to be happening on our client site is that a third party tool is going to send a message to the queue containing some data in the ApplIdentityData property. I will then be required to read this header information from the message (in the past we have just read the actual message data and ignored anything in the header) and process this.
If you are right in thinking this header property can't be written to then I will have serious problems in testing any code I produce
Does anyone have any code pertaining to the WebSphere MQ .Net classes (i.e. not using the XMS or JMS APIs) where they have successfully called SetStringProperty and then subsequently read that info back using GetStringProperty?
Thanks |
Like I said, this information is carried on the MQMD and not as a message property. Trying to access it as a message property will fail. It can be set (by a non JMS, non XMS app), but again as a field on the MQMD and not as a property. Again please read the programming manual.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
MQLuvin |
Posted: Thu Aug 26, 2010 8:15 am Post subject: |
|
|
Newbie
Joined: 26 Aug 2010 Posts: 5
|
Does anyone have anything other than rtfm?
A link to the relevant tutorials/code samples on talking to amdmqnet.dll V7 perhaps?
Thanks |
|
Back to top |
|
 |
Vitor |
Posted: Thu Aug 26, 2010 8:36 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
MQLuvin wrote: |
Does anyone have anything other than rtfm? |
In this instance it's sound advice as the point my associate is driving at is that what you're trying to use as a property isn't a property & the manual in question describes how you can both set and read it using .NET.
MQLuvin wrote: |
A link to the relevant tutorials/code samples on talking to amdmqnet.dll V7 perhaps? |
There are .NET samples supplied with the product. If they weren't installed when the base software was installed speak to whoever does the installs at your site and/or whoever's got the install media. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
MQLuvin |
Posted: Fri Aug 27, 2010 12:43 am Post subject: |
|
|
Newbie
Joined: 26 Aug 2010 Posts: 5
|
The .Net samples that ship with the WebSphere MQ client V7.0 all pertain to XMS which means they are of no value whatsoever (i.e. the code all begins with using IBM.XMS;, whereas I need using IBM.WMQ;).
Anyway I guess the hint that I'm barking up the wrong tree trying to read a property is a start. But comments like "the relevant manual" or "the manual in question" are understandably irritating when you've been trying to find the relevant manual for a week. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Aug 27, 2010 2:01 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
MQLuvin wrote: |
The .Net samples that ship with the WebSphere MQ client V7.0 all pertain to XMS which means they are of no value whatsoever (i.e. the code all begins with using IBM.XMS;, whereas I need using IBM.WMQ;). |
the samples that ship with the client install should be the same as the samples that ship with the server install and should include nmqsput.cs and nmqget.cs, and MQMessagePropertiesSample.cs.
Telling you that you need to get at ApplIdentityData from the MQMD rather than from the properties should be enough to solve this problem for you. It really shouldn't be difficult at all to get it.
You may find it more effort than you expect it to be to try and create a new message that has a custom value for ApplIdentityData, especially in anything other than Java. |
|
Back to top |
|
 |
MQLuvin |
Posted: Fri Aug 27, 2010 4:07 am Post subject: |
|
|
Newbie
Joined: 26 Aug 2010 Posts: 5
|
Oh yes, there are indeed some sneakily hidden files in there that aren't part of Samples.sln. Thanks.
There is a property on MQMessage called ApplicationIDData, perhaps this is what I can use. I'll see if I can use the MQ API Exerciser to put a message with ApplIdentityData onto the queue. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Aug 27, 2010 7:06 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
MQLuvin wrote: |
But comments like "the relevant manual" or "the manual in question" are understandably irritating when you've been trying to find the relevant manual for a week. |
Obviously you did not see the links at the top of the page (Library, and Infocenter). If you follow the Library link you get the V7 libraries and then go to the Infocenter... That should give you all the manuals you need... including the using .NET manual...
http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.doc/help_home_wmq.htm  _________________ MQ & Broker admin |
|
Back to top |
|
 |
shashikanth_in |
Posted: Wed Sep 08, 2010 1:30 am Post subject: |
|
|
Centurion
Joined: 26 Feb 2009 Posts: 123
|
GetStringProperty and SetStringProperty methods can only be used for user defined properties.
For example
msg.SetStringProperty("StockName","MYCOMP");
msg.GetStringProperty("StockName") will give you "MYCOMP".
ApplicationIdentity is part of MQMD. Hence you should use msg.ApplicationIdData property. |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed Sep 08, 2010 2:32 pm Post subject: Re: How can I read ApplIdentityData using WebSphere .Net Cla |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
MQLuvin wrote: |
Code: |
MQMessage msg = new MQMessage();
...
msg.SetStringProperty("ApplIdentityData", "MyValue"); |
|
I think you are confused on how to access the message's MD (MQMD):
Code: |
MQPutMessageOptions pmo = new MQPutMessageOptions();
MQMessage sendmsg = new MQMessage();
sendmsg.Format = MQC.MQFMT_STRING;
sendmsg.Feedback = MQC.MQFB_NONE;
sendmsg.MessageType = MQC.MQMT_DATAGRAM;
sendmsg.MessageId = MQC.MQMI_NONE;
sendmsg.CorrelationId = MQC.MQCI_NONE;
sendmsg.ApplicationIdData = "Roger"; // Sadly, this will not work!
sendmsg.WriteString("This is a test message");
queue.Put(sendmsg, pmo); |
But it is not as simply as that because ApplicationIdData field is a "Context Identity" field. Hence, you must open the queue with the MQOO_SET_IDENTITY_CONTEXT option and use the correct PMO option.
Code: |
int openOptions = MQC.MQOO_OUTPUT + MQC.MQOO_SET_IDENTITY_CONTEXT + MQC.MQOO_FAIL_IF_QUIESCING;
MQQueueManager _qMgr = new MQQueueManager(qManager);
MQQueue queue = _qMgr.AccessQueue(outputQName, openOptions, null, null, null);
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options += MQC.MQPMO_SET_IDENTITY_CONTEXT
MQMessage sendmsg = new MQMessage();
sendmsg.Format = MQC.MQFMT_STRING;
sendmsg.Feedback = MQC.MQFB_NONE;
sendmsg.MessageType = MQC.MQMT_DATAGRAM;
sendmsg.MessageId = MQC.MQMI_NONE;
sendmsg.CorrelationId = MQC.MQCI_NONE;
sendmsg.ApplicationIdData = "Roger";
sendmsg.WriteString("This is a test message");
queue.Put(sendmsg, pmo); |
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
|