Author |
Message
|
sarovaithi |
Posted: Tue May 03, 2011 12:15 pm Post subject: Put Message with RFH2 Header in MQ from VB.NET |
|
|
Newbie
Joined: 03 May 2011 Posts: 5
|
Hi,
I am having an issue with putting data in the usr folder in MQ from VB.Net application.
I having no problem puting the messages, the body of the message going correctly, i am trying to put some data in the usr folder, but when i browse the message using rfhutilc all RFH2 folders appaers in the "message data" not in usr tab.
Can anyonle please help me on this?
My sample code is below:
--------------------------------------------------------------------------
Imports IBM.WMQ
'Imports IBM.WMQSOAP
'Imports IBM.XMS
Dim strUsr As String = "<msgtype>TestMsgType</msgtype>"
Dim strUSRBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(strUsr)
Dim iMsgLen As Integer = (CInt((strUsr.Length)))
PutMsg = New MQMessage
PutMsg.Format = MQC.MQFMT_RF_HEADER_2
PutMsg.WriteString(MQC.MQRFH_STRUC_ID) ' StrucID
PutMsg.WriteInt4(MQC.MQRFH_VERSION_2) ' Version
PutMsg.WriteInt4(MQC.MQRFH_STRUC_LENGTH_FIXED_2 + iMsgLen) ' StrucLength
PutMsg.WriteInt4(MQC.MQENC_NATIVE) ' Encoding
PutMsg.WriteInt4(MQC.MQCCSI_DEFAULT) ' CodedCharSetID
PutMsg.WriteString(MQC.MQFMT_RF_HEADER_2) ' Format
PutMsg.WriteInt4(MQC.MQRFH_NO_FLAGS) ' Flags
PutMsg.WriteInt4(1208) ' NameValueCCSID
PutMsg.WriteInt4(iMsgLen) 'NameValueLength <jms>
PutMsg.WriteString(strUsr) ' NameValueData <usr>
MESSAGE = "<?xml version=""1.0"" encoding=""UTF-8""?><AAA><BBB>TEST</BBB></AAA>"
PutOptions = New MQPutMessageOptions()
PutMsg.WriteString(MESSAGE)
putmsg.Write(
Queue.Put(PutMsg, PutOptions)
-------------------------------------------------------------------------------- |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue May 03, 2011 12:18 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Moving to more appropriate forum.
If you are using an RFH header you'd be better advised to use XMS than try building your own. There is the little problem of alignment etc...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
sarovaithi |
Posted: Tue May 03, 2011 12:32 pm Post subject: |
|
|
Newbie
Joined: 03 May 2011 Posts: 5
|
I have triet to use XMS...but i dont have any idea how to use that API...Does anybody have some sample code?
Regards,
Saro |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue May 03, 2011 12:34 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
sarovaithi wrote: |
I have triet to use XMS...but i dont have any idea how to use that API...Does anybody have some sample code?
Regards,
Saro |
Look up on the net an exemple of JMS. XMS is nothing else but JMS ported to a non Java environment...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mvic |
Posted: Tue May 03, 2011 12:48 pm Post subject: |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
|
Back to top |
|
 |
shashikanth_in |
Posted: Tue May 03, 2011 7:57 pm Post subject: |
|
|
Centurion
Joined: 26 Feb 2009 Posts: 123
|
I believe you are trying to set some user properties. Have you tried using methods like SetIntProperty(), SetStringProperty() of MQMessage class? These methods can be used to set user defined properties.
For example:
Try
msg = New MQMessage()
msg.WriteUTF("This is a test message from VB app with properties")
msg.SetStringProperty("MyProp", "value")
q.Put(msg)
Catch ex As Exception
Console.Write(ex)
End Try |
|
Back to top |
|
 |
shashikanth_in |
Posted: Tue May 03, 2011 7:58 pm Post subject: |
|
|
Centurion
Joined: 26 Feb 2009 Posts: 123
|
Adding my update above: I use MQ v7. |
|
Back to top |
|
 |
sarovaithi |
Posted: Wed May 04, 2011 5:22 am Post subject: |
|
|
Newbie
Joined: 03 May 2011 Posts: 5
|
Thanks a lot. Now it works fine. Now I am able to see the value in usr folder. Thanks for your help.
Regards,
V. Saro |
|
Back to top |
|
 |
sarovaithi |
Posted: Fri May 06, 2011 5:22 am Post subject: |
|
|
Newbie
Joined: 03 May 2011 Posts: 5
|
Now i am able to put value into the USR folder. Now I have one small issue there. I am trying to put a below value into the usr folder.
<Test>Test Message</Test>
When i check the message in USR folder throught RFHUtil, it shows as below
<Test dt="string">Test Message</Test>.
Is there anyway to eliminate dt="string" from that tag? |
|
Back to top |
|
 |
mvic |
Posted: Fri May 06, 2011 5:34 am Post subject: |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
sarovaithi wrote: |
Is there anyway to eliminate dt="string" from that tag? |
I think the answer is probably "no".
Out of interest, why do you need to eliminate it? |
|
Back to top |
|
 |
sarovaithi |
Posted: Fri May 06, 2011 6:05 am Post subject: |
|
|
Newbie
Joined: 03 May 2011 Posts: 5
|
We are putting messges there and the other team read that message and do further process.
I have asked the same question to that team, no answer from them. They keep on ask us that can we send without that element dt="string" |
|
Back to top |
|
 |
Vitor |
Posted: Fri May 06, 2011 6:07 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sarovaithi wrote: |
They keep on ask us that can we send without that element dt="string" |
Strictly speaking it's an attribute not an element, which is why it shouldn't make any difference. Except to help a well-behaved recieving application.
I agree with my most worthy associate that there's probably nothing you can do. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mvic |
Posted: Fri May 06, 2011 6:18 am Post subject: |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
sarovaithi wrote: |
They keep on ask us that can we send without that element dt="string" |
Maybe they would like to say the reason.
I think the dt="string" is there because it is intended to be useful. If it is missing, something else might break when you least expect it.
Are they using some incompatible libraries for parsing messages? Maybe (just my opinion) when you are originating a message using MQ-provided classes, it should be consumed using MQ-provided classes too, to give greatest chance of success. |
|
Back to top |
|
 |
Vitor |
Posted: Fri May 06, 2011 6:25 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mvic wrote: |
I think the dt="string" is there because it is intended to be useful. |
AFAIK it's intended to describe the datatype of the content for casting & conversion purposes. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Fri May 06, 2011 7:04 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
Vitor wrote: |
mvic wrote: |
I think the dt="string" is there because it is intended to be useful. |
AFAIK it's intended to describe the datatype of the content for casting & conversion purposes. |
I think that if this attribute isnt present then the data is assumed to be a string (I certainly dont remember dt="string" all over the elements in the usr folder when using JMS).
Its probably that the XMS API is adding it in to be nice, I dont know if theres a way to disable it however and as you say, theres probably no need. |
|
Back to top |
|
 |
|