Author |
Message
|
Waltari |
Posted: Tue May 29, 2007 7:21 am Post subject: How to read many message from MQQueue |
|
|
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 |
|
 |
rparti |
Posted: Tue May 29, 2007 7:25 am Post subject: |
|
|
 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 |
|
 |
sebastianhirt |
Posted: Tue May 29, 2007 7:25 am Post subject: Re: How to read many message from MQQueue |
|
|
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 |
|
 |
Waltari |
Posted: Tue May 29, 2007 7:27 am Post subject: |
|
|
Novice
Joined: 16 May 2007 Posts: 14
|
Sorry, you are right, Im MQ client |
|
Back to top |
|
 |
Waltari |
Posted: Tue May 29, 2007 7:30 am Post subject: |
|
|
Novice
Joined: 16 May 2007 Posts: 14
|
How know how many messages there are in your queue, when you are client? |
|
Back to top |
|
 |
rparti |
Posted: Tue May 29, 2007 7:38 am Post subject: |
|
|
 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 |
|
 |
Waltari |
Posted: Tue May 29, 2007 7:42 am Post subject: |
|
|
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 |
|
 |
Vitor |
Posted: Tue May 29, 2007 7:44 am Post subject: |
|
|
 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 |
|
 |
Waltari |
Posted: Tue May 29, 2007 7:48 am Post subject: |
|
|
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 |
|
 |
atheek |
Posted: Tue May 29, 2007 7:49 am Post subject: |
|
|
 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 |
|
 |
Vitor |
Posted: Tue May 29, 2007 7:50 am Post subject: |
|
|
 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 |
|
 |
Waltari |
Posted: Tue May 29, 2007 7:53 am Post subject: |
|
|
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 |
|
 |
|