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 Java / JMS » How to read many message from MQQueue

Post new topic  Reply to topic
 How to read many message from MQQueue « View previous topic :: View next topic » 
Author Message
Waltari
PostPosted: Tue May 29, 2007 7:21 am    Post subject: How to read many message from MQQueue Reply with quote

Novice

Joined: 16 May 2007
Posts: 14

Hi Folks.

I have a problem, I want to know how many messages I have in the Queue, but when Im connecting in the queue, I cant access this property "CurrentDepth", I dont know what happened, anyone can helps me plz, Im connecting one remote Queue. Or anyone knows other way like to know how many messsage there are in one Queue

this is my piece of code

MQmanejador = New MQQueueManager(MQmc)
MQmanejador.Connect()

MQcola = MQmanejador.AccessQueue(MQnc, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_INQUIRE +MQC.MQGMO_FAIL_IF_QUIESCING)
Dim contador = MQcola.CurrentDepth

MQgetmensajeopcion = New MQGetMessageOptions
MQgetmensajeopcion.Options = MQC.MQGMO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING
MQgetmensajeopcion.WaitInterval = 15000 ' 15 second limit for waiting
MQmensaje = New MQMessage
MQmensaje.Format = MQC.MQFMT_STRING
MQcola.Get(MQmensaje, MQgetmensajeopcion)
While (MQgetmensajeopcion.GroupStatus <> MQC.MQGS_LAST_MSG_IN_GROUP)
Dim Filemsj As StreamWriter = New StreamWriter("C:\Fasa1\ejemplo1.text")
Filemsj.Write(MQmensaje.ReadString(MQmensaje.MessageLength))
Filemsj.Close()
MQgetmensajeopcion = New MQGetMessageOptions
MQgetmensajeopcion.Options = MQC.MQGMO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING
MQgetmensajeopcion.WaitInterval = 15000 ' 15 second limit for waiting
MQmensaje = New MQMessage
MQmensaje.Format = MQC.MQFMT_STRING
MQcola.Get(MQmensaje, MQgetmensajeopcion)
End While
Back to top
View user's profile Send private message MSN Messenger
rparti
PostPosted: Tue May 29, 2007 7:25 am    Post subject: Reply with quote

Voyager

Joined: 05 Oct 2005
Posts: 86
Location: U.S.A.

You cannot get messages from a remote queue.

You can get messages only from local queues.

Please read the manuals before you post here. Or use the search in this forum. It is very handy.
Back to top
View user's profile Send private message
sebastianhirt
PostPosted: Tue May 29, 2007 7:25 am    Post subject: Re: How to read many message from MQQueue Reply with quote

Yatiri

Joined: 07 Jun 2004
Posts: 620
Location: Germany

Waltari wrote:
Hi Folks.

I have a problem, I want to know how many messages I have in the Queue, but when Im connecting in the queue, I cant access this property "CurrentDepth", I dont know what happened, anyone can helps me plz, Im connecting one remote Queue. Or anyone knows other way like to know how many messsage there are in one Queue


Remote queues don't have a current depth.
Messages can not be gotten from a remote queue.
Back to top
View user's profile Send private message
Waltari
PostPosted: Tue May 29, 2007 7:27 am    Post subject: Reply with quote

Novice

Joined: 16 May 2007
Posts: 14

Sorry, you are right, Im MQ client
Back to top
View user's profile Send private message MSN Messenger
Waltari
PostPosted: Tue May 29, 2007 7:30 am    Post subject: Reply with quote

Novice

Joined: 16 May 2007
Posts: 14

How know how many messages there are in your queue, when you are client?
Back to top
View user's profile Send private message MSN Messenger
rparti
PostPosted: Tue May 29, 2007 7:38 am    Post subject: Reply with quote

Voyager

Joined: 05 Oct 2005
Posts: 86
Location: U.S.A.

If you are a client, you will specify host name and channel information in MQEnvironment.
You will also define a Sever Connection Channel.

Check previous posts. There is a ton of information.
Read the MQClient manual too
Back to top
View user's profile Send private message
Waltari
PostPosted: Tue May 29, 2007 7:42 am    Post subject: Reply with quote

Novice

Joined: 16 May 2007
Posts: 14

yeah I had all this, look I can get one message, but I wanna do that my aplication gets all the message, my application is connect to queue reads one message and disconnect and I wanna do that reads all the messages.

MQEnvironment.Hostname = "10.129.4.228"
MQEnvironment.Channel = ConfigurationSettings.AppSettings.Get("MQcanal")
MQEnvironment.Port = CType("1414", Integer)
Back to top
View user's profile Send private message MSN Messenger
Vitor
PostPosted: Tue May 29, 2007 7:44 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Waltari wrote:
yeah I had all this, look I can get one message, but I wanna do that my aplication gets all the message, my application is connect to queue reads one message and disconnect and I wanna do that reads all the messages.


So loop round until all the messages are gone......

You'll find many examples of this on the forum and in the samples.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Waltari
PostPosted: Tue May 29, 2007 7:48 am    Post subject: Reply with quote

Novice

Joined: 16 May 2007
Posts: 14

Yea Vitor, but when I read the last message I get error like this "Error in the application", and how know that you queue is empty?

my piece of code is

MQcola = MQmanejador.AccessQueue(MQnc, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_INQUIRE)
Dim contador = MQcola.CurrentDepth.ToString

MQgetmensajeopcion = New MQGetMessageOptions
MQgetmensajeopcion.Options = MQC.MQGMO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE
MQgetmensajeopcion.WaitInterval = 15000 ' 15 second limit for waiting
MQmensaje = New MQMessage
MQmensaje.Format = MQC.MQFMT_STRING
MQcola.Get(MQmensaje, MQgetmensajeopcion)
While (MQgetmensajeopcion.GroupStatus <> MQC.MQGS_LAST_MSG_IN_GROUP) <--------Here is my loop
Dim Filemsj As StreamWriter = New StreamWriter("C:\Fasa1\ejemplo1.text")
Filemsj.Write(MQmensaje.ReadString(MQmensaje.MessageLength))
Filemsj.Close()
MQgetmensajeopcion = New MQGetMessageOptions
MQgetmensajeopcion.Options = MQC.MQGMO_WAIT '+ MQC.MQGMO_FAIL_IF_QUIESCING
MQgetmensajeopcion.WaitInterval = 15000 ' 15 second limit for waiting
MQmensaje = New MQMessage
MQmensaje.Format = MQC.MQFMT_STRING
MQcola.Get(MQmensaje, MQgetmensajeopcion)<----- Here I get the error when my application reads the last message End While
Back to top
View user's profile Send private message MSN Messenger
atheek
PostPosted: Tue May 29, 2007 7:49 am    Post subject: Reply with quote

Partisan

Joined: 01 Jun 2006
Posts: 327
Location: Sydney

Quote:


So loop round until all the messages are gone......


..to be specific until you get a 2033 reason code
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue May 29, 2007 7:50 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Waltari wrote:
Yea Vitor, but when I read the last message I get error like this "Error in the application", and how know that you queue is empty?


If you actually look at the error you're getting, I'll wager it's a 2033 "no matching messages in queue" error.

You'll find this documented in the manuals, discussed on the forum and in the majority of the sample code...
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Waltari
PostPosted: Tue May 29, 2007 7:53 am    Post subject: Reply with quote

Novice

Joined: 16 May 2007
Posts: 14

Ok guys, sorry I will try their advice, but Im new with Websphere, ok, let me try their advice, ok and thanks a lot
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » How to read many message from MQQueue
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.