Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable To Browse Messages 1

Status
Not open for further replies.

smakiso

Programmer
Jun 16, 2003
3
US
Could someone please post some sample code which uses the MQGMO_BROWSE_FIRST and MQGMO_BROWSE_NEXT? I am able to browse the first message in the queue, but I am unable to browse any messages after the first. Thanks!
 
It would be much easier if you post your code for us to modify it rather than someone supplying you the code for the same. I dont have it right now, else i could have posted it here.



Cheers
KK
 
Sorry about not posting the code. Here it is. I get an error (Completion Code=2, ReasonCode=2033, Reason=MQRC_NO_MSG_AVAILABLE) on the second "qQue.Get" statement. It gets the first message successfully, but errors on the second message. Thanks for your help!

Dim qSes As New MQAX200.MQSession()
Dim qMgr As MQAX200.MQQueueManager
Dim qQue As MQAX200.MQQueue
Dim qMsg As MQAX200.MQMessage
Dim qGmo As MQAX200.MQGetMessageOptions
Dim cnt As Int16

Try
qMgr = qSes.AccessQueueManager(txtOutputMgr.Text)
qQue = qMgr.AccessQueue(txtOutputQ.Text, MQOO_BROWSE + MQOO_INQUIRE)
qMsg = qSes.AccessMessage()
qGmo = qSes.AccessGetMessageOptions()

For cnt = 1 To qQue.CurrentDepth
Dim Item As New ListViewItem()

If cnt = 1 Then
qGmo_Options = MQAX200.MQ.MQGMO_BROWSE_FIRST
Else
qGmo_Options = MQAX200.MQ.MQGMO_BROWSE_NEXT
End If
Next cnt

qQue.Get(qMsg, qGmo)

Catch
 
Looks like a VB program. I am not a specialist on it, but shall try.

First of all i dont know how it works. Because looking at the program, the Get is being doine outside the for loop, so not sure how you are able to even do the second get.

If it is already in the loop, which i dont see. You need to reset the qMsg.MessageId and qMsg.CorrelationId to MQMI_NONE and MQCI_NONE respectively in your app after you get each message. Because after you get a message, these attributes hold the values from the 1st message. Unless you reset them, MQ searches for the next message with these values.

Hope this helps.


Cheers
KK
 
Thank you very much for your help! I set both the message ID and correlation ID = "" and it worked. I read the constants you provided (MQMI_NONE and MQCI_NONE) are not supported by the MQ Automation Classes for ActiveX, but using the empty string has the same effect.

BTW, the qQue.Get statement is in the for loop, I pasted it incorrectly. Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top