-
Nov 8th, 2017, 02:24 PM
#1
Thread Starter
New Member
VB.net Code to do an MQGET and MQPUT by MessageID
I'm trying to use VB.net to GET a message from MQ, (save the MessageId) then put a message to MQ with the same MESSAGE ID using VB.net. The problem I'm getting is after I do the MQGET, I try to save the Message ID to a string, then when I do the MQPUT and specify the same Message ID, the program just bombs. It doesn't like something with how I store the Message id.
I get the message and do the following which seems to work.
Save_md = System.Text.Encoding.UTF8.GetString(mqMsg.MessageId) <= saves the message id from the get to variable save_md.
Now I later try to put messages with that message id in Save_md. Here is the code.
mqMsg.MessageId = System.Text.Encoding.UTF8.GetBytes(Save_md)
Once it hits this line, it just bombs the program. So I'm guessing it is something with the conversion from BYTES to text and back and forth. I've looked around for better ways to do it, but I can't seem to find it for vb.net.
Does anyone have any ideas?
Thanks,
Gary
-
Nov 8th, 2017, 04:25 PM
#2
Re: VB.net Code to do an MQGET and MQPUT by MessageID
"just bombs the program" -- what does that mean? does it blow up? Or do you get an error message of some kind? If so, what is the error message?
If I had to guess, the MessageID is a string, so it's looking for a string and you're passing a bunch of bytes - an array of bytes to be exact. Odds are you're getting some sort of invalid conversion/cast/invalid data type error.
But it's just a guess as I don't even know what MQ is or how it works.
-tg
-
Nov 11th, 2017, 01:44 AM
#3
Re: VB.net Code to do an MQGET and MQPUT by MessageID
What I'd like to know is what kinds of objects are these. What is MQ? Is it some kind of library or class? What is MQPUT? What kind of object is mqMsg referencing? What are these classes?
-
Nov 14th, 2017, 06:33 AM
#4
Thread Starter
New Member
Re: VB.net Code to do an MQGET and MQPUT by MessageID
Well I figured out what the problem was. The MessageId is a BYTE format and my conversion to String was failing. Just to follow up, MQ is IBM's MQSeries. So it is a class provided to VB.net with various objects like mqMsg and mqMsg.messageid, etc. I was just having trouble finding the right code to use when trying to save the messageid. Anyways, I did figure it out. Thanks for the quick responses. Sorry it took me a day or so to respond, as I was out of the office.
Thanks again!
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|