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 » How to get all the mesages in Message Queue?

Post new topic  Reply to topic
 How to get all the mesages in Message Queue? « View previous topic :: View next topic » 
Author Message
hoa_lan_trang1982
PostPosted: Tue Nov 21, 2006 12:38 am    Post subject: How to get all the mesages in Message Queue? Reply with quote

Newbie

Joined: 15 Nov 2006
Posts: 7

Hi all!
I have a .NET application that get messages from Message Queue but I when I used OutputQueue.Get(retrievedMessage, gmo) function that return only 1 message in that Message Queue. I don't know how to get all the messages in that Message Queu.
Can you help me?
Thanks!
Back to top
View user's profile Send private message
tariq
PostPosted: Tue Nov 21, 2006 1:17 am    Post subject: do it using a loop Reply with quote

Newbie

Joined: 20 Jun 2006
Posts: 6

Dim msgList As ArrayList
msgList = New ArrayList
mqQueue = mqQMgr.AccessQueue(queueName, MQC.MQOO_BROWSE + MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING)
Dim mqGetMsgOpts As MQGetMessageOptions '* MQGetMessageOptions instance
mqGetMsgOpts = New MQGetMessageOptions
mqGetMsgOpts.WaitInterval = 15000 '* 15 second limit for waiting
mqGetMsgOpts.Options = MQC.MQGMO_BROWSE_NEXT

Dim isContinue As Boolean = True
Do While (isContinue = True)
Dim mqMsg As MQMessage '* MQMessage instance
mqMsg = New MQMessage

Try
mqQueue.Get(mqMsg, mqGetMsgOpts)
If (mqMsg.Format.CompareTo(MQC.MQFMT_STRING) = 0) Then
msgList.Add(mqMsg)
'output.Append(mqMsg.ReadString(mqMsg.MessageLength) + vbCrLf)
'txtOutput.Text = output.ToString()
Else
output.Append("No-text message" + vbCrLf)
txtOutput.Text = output.ToString()
End If

Catch mqe As MQException
'* report reason, if any
If (mqe.Reason = MQC.MQRC_NO_MSG_AVAILABLE) Then
'* special report for normal end
output.Append("Non-text message" + vbCrLf)
txtOutput.Text = output.ToString()
isContinue = False
Else
'* general report for other reasons
output.Append("MQQueue::Get ended with {0} " + mqe.Message + vbCrLf)
txtOutput.Text = output.ToString()

'* treat truncated message as a failure for this sample
If (mqe.Reason = MQC.MQRC_TRUNCATED_MSG_FAILED) Then
isContinue = False
End If
End If
End Try
Loop

grdMessages.DataSource = msgList
grdMessages.Refresh()
Back to top
View user's profile Send private message
kevinf2349
PostPosted: Tue Nov 21, 2006 5:47 am    Post subject: Reply with quote

Grand Master

Joined: 28 Feb 2003
Posts: 1311
Location: USA

Quote:
but I when I used OutputQueue.Get(retrievedMessage, gmo) function that return only 1 message in that Message Queue.


Thats because that is all MQ will ever do. You have to write your application to loop through to read them all.

Crack open the Application Programmers Guide, read it, understand it and then all will become clearer.
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 » How to get all the mesages in Message Queue?
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.