VB.net Code to do an MQGET and MQPUT by MessageID-VBForums
Results 1 to 4 of 4

Thread: VB.net Code to do an MQGET and MQPUT by MessageID

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    8

    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

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,182

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    5,425

    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?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    8

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.