ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » MQGET works, but the read throws a 2195

Post new topic  Reply to topic
 MQGET works, but the read throws a 2195 « View previous topic :: View next topic » 
Author Message
PeterPotkay
PostPosted: Thu Nov 18, 2004 3:51 pm    Post subject: MQGET works, but the read throws a 2195 Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

5.3.0.8
Windows XP SP1


In the below VB.NET code, the MQGET returns a 2033, but the read of the message into the buffer throws a 2195. What am I doing wrong. I am trying to follow the example in the .NET manual on how to read an MQ message into the buffer.

The message is being taken off of the queue, and I can read its attributes, like Persistence. But if I try and stick it in the buffer, I get a 2195 MQRC_UNEXPECTED_ERROR.



Code:

             Try
                myQM = New MQQueueManager(QMName, myHashTable)
               
                '**************************************************
                '    Open the Queue
                '**************************************************
                openOptions = 0
                openOptions = openOptions + MQC.MQOO_INPUT_SHARED + MQC.MQOO_INQUIRE + MQC.MQOO_FAIL_IF_QUIESCING
                myQ = myQM.AccessQueue(screenQueueName, openOptions)
               
               
                gmo = New MQGetMessageOptions
                getOptions = 0
                getOptions = getOptions + MQC.MQGMO_FAIL_IF_QUIESCING + MQC.MQGMO_WAIT
                gmo.Options = getOptions
                gmo.WaitInterval = 10000

                myMsg = New MQMessage 'create a buffer to hold the incoming message

                Do 'Until EndOfLoop
                    '**************************************************
                    '    Start issuing MQGETs in a loop
                    '**************************************************

                    Try
                       
                        With myMsg
                            .MessageId = MQC.MQMI_NONE
                            .CorrelationId = MQC.MQCI_NONE
                            .ClearMessage()
                        End With

                        myQ.Get(myMsg, gmo) <<<<THIS WORKS

                        Dim MyPersistence As String
                        MyPersistence = myMsg.Persistence <<<THIS WORKS

                        Dim myMsgTxt As String
                        myMsgTxt = myMsg.ReadUTF <<<THIS THROWS A 2195

                       
                        If myMsg.Feedback = MQC.MQFB_QUIT Then
                            EndOfLoop = True
                        End If

                    Catch mqError As MQException
                        Select Case mqError.ReasonCode
                            Case MQC.MQRC_NO_MSG_AVAILABLE
                                'continue
                            Case Else
                                EndOfLoop = True
                        End Select
                    End Try
                Loop Until EndOfLoop

            Catch mqError As MQException
                 'MQCONN or MQOPEN failed. Add error logic here.
            End Try

_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Nov 18, 2004 5:08 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Peter,

I trust that your message has been written to as writeUTF and is not just a plain and simple text message.

Remember that UTF message vs Text message has 2 more bytes at the beginning...

Hope it helps
F.J.
Back to top
View user's profile Send private message Send e-mail
PeterPotkay
PostPosted: Thu Nov 18, 2004 5:27 pm    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

Ughhhhh....?

I put the message in the queue using MQExplorer. I can browse it using other tools. Is ReadUTF not the correct thing to do here?
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Nov 18, 2004 5:35 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

PeterPotkay wrote:
I put the message in the queue using MQExplorer.


Couldn't you at least have used that overpriced "developer" tool you have lying around?

Likely MQExplorer wrote the data in Windows standard CCSID, rather than Unicode.

Try using the .NET sample put program instead.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Nov 18, 2004 5:36 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

No readUTF is not the correct thing to do there.
Try any of the other read methods and you should be fine.
Remember UTF has specific characteristics....

Enjoy
Back to top
View user's profile Send private message Send e-mail
kirani
PostPosted: Thu Nov 18, 2004 5:48 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Try using ReadString method.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
PeterPotkay
PostPosted: Thu Nov 18, 2004 8:39 pm    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

I was looking at that ReadString method, but it takes an int length parameter.

Quote:

public String ReadString(int length) Throws IOException, EndOfStreamException.

Reads a string in the codeset identified by the characterSet member variable, and convert it into Unicode.

Parameters:
length: The number of characters to read (which may differ from the number of bytes according to the codeset, because some codesets use more than one byte per character).


What I don't understand here is what value would I pass in as int? 100 MEG, just to be sure I can take the largest message MQ can provide? Or pick a smaller number, and risk not reading the entire buffer?

I want to be able to read the message regardless of where it came from, or whether it was UTF or not. So I guess readString is the correct read method with that in mind?

Why would you want to use ReadUTF? Only if you were 100% sure the sending program was sending UTF? Seems a bit constraining if so.....
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
kirani
PostPosted: Thu Nov 18, 2004 11:32 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

PeterPotkay wrote:

What I don't understand here is what value would I pass in as int? 100 MEG, just to be sure I can take the largest message MQ can provide? Or pick a smaller number, and risk not reading the entire buffer?

I'd specify maximun size for the message.

PeterPotkay wrote:

I want to be able to read the message regardless of where it came from, or whether it was UTF or not. So I guess readString is the correct read method with that in mind?

Yes.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
fjb_saper
PostPosted: Fri Nov 19, 2004 1:54 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Peter,

Isn't there a method on the message that allows you to get the payload length? If you call that one up first and only then the read method you can determine how big your buffer needs to be before reading the message.

Enjoy
Back to top
View user's profile Send private message Send e-mail
PeterPotkay
PostPosted: Fri Nov 19, 2004 2:03 pm    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

Yes, I fingered that out! Thanks for your help guys.

My Frankenstein program is breathing.......now to get it to do something useful.
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
kirani
PostPosted: Fri Nov 19, 2004 3:02 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Peter,

There are two attributes (DataLength and MessageLength), which gets populated after MQGET call. Does that help you?
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
PeterPotkay
PostPosted: Fri Nov 19, 2004 3:07 pm    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

Yes, that is what I am using. I am familiar with the MQ API because I wrote our COBOL MQ wrapper programs. Its translating this knowledge into an object oriented language that is tough. Basically I am trying to learn VB.NET at the same time I am writing this.

The pure MQ stuff I am cool with. Its the VB.NET stuff like reading strings that confooooses me!

My little app will be like sausages :you don't want to see it being made, but the end product is oh so good!
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » MQGET works, but the read throws a 2195
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.