Author |
Message
|
jsnagi |
Posted: Tue Oct 17, 2006 11:35 am Post subject: # of messages in a Queue (C# of VB.NET) |
|
|
Newbie
Joined: 17 Oct 2006 Posts: 3
|
I have this code that gets' and puts' info in the MQ. In this code all I am trying to do is get the # of messages in the Queue, if there are any. And then based on that I want to do some login. Here's the code, that I have and it does not seem to work. Any help on this matter will be greatly appreciated.
+++++++++++++++++++++++++++++++
public void getMessageFromTheQueue()
{
QMgr = new IBM.WMQ.MQQueueManager(_QueueManagerName,_ChannelName,_ConnectionName);
Q = QMgr.AccessQueue(_QueueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
QMsg = new IBM.WMQ.MQMessage();
QMsg.Format = MQC.MQFMT_STRING;
QGetMessageOptions = new IBM.WMQ.MQGetMessageOptions();
try
{
int QCount = Q.CurrentDepth(MQC.MQQA_GET_ALLOWED); //the code fails at this point
Debug.Write(QCount);
Q.Get(QMsg,QGetMessageOptions);
statusBar.Text = ("Received Message: {0}" + QMsg.ReadString(QMsg.MessageLength));
}
catch (System.Exception e)
{
string err = e.Message;
statusBar.Text = ("MQQueue::Get ended with " + err);
}
}
+++++++++++++++++++++++++++++++ |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Oct 17, 2006 11:44 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You have to open a queue for Inquire if you want to get the current depth the way you are trying to do it.
Generally, it is a bad idea to make any decisions based on the current depth inside a program that is putting and getting messages.
If you are trying to write a monitoring program, then you should really look at the Inquire Queue PCF command or the DIS QLOCAL MQSC command. Both of those will return you the CURDEPTH of the queue.
But if you are trying to react to queue depth changes, you should really look at Queue Depth Events. There's an entire manual on WebSphere MQ Monitoring and Events. You should start there. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jsnagi |
Posted: Tue Oct 17, 2006 12:14 pm Post subject: |
|
|
Newbie
Joined: 17 Oct 2006 Posts: 3
|
Thanks for responding... I browsed the IBM.WMQ.PCF / WMQ and WMQAX objects. I was hoping to see something in WMQ.PCF. I so not see anything in there that I can work against to monitor the queue.
I have the Websphere MQ and the .NET document.... nothing listed in it. Can you point me to some specific place where I can find that info? maybe some samples? Please advice. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Oct 17, 2006 12:15 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
A cursory search of this site here will find you a ton of links and some recent threads with sample code.
Please don't be lazy. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jsnagi |
Posted: Tue Oct 17, 2006 12:27 pm Post subject: |
|
|
Newbie
Joined: 17 Oct 2006 Posts: 3
|
Thankyou.... I'll just do that. Intention is not to be lazy, but to save me some time! I have only been looking for this info and trying to make it work since yesterday. Anyhow, will do the search right now as you sugested. |
|
Back to top |
|
 |
IanB |
Posted: Wed Oct 18, 2006 2:13 am Post subject: |
|
|
Apprentice
Joined: 13 Oct 2006 Posts: 43
|
jsnagi wrote: |
Thanks for responding... I browsed the IBM.WMQ.PCF / WMQ and WMQAX objects. I was hoping to see something in WMQ.PCF. I so not see anything in there that I can work against to monitor the queue.
I have the Websphere MQ and the .NET document.... nothing listed in it. Can you point me to some specific place where I can find that info? maybe some samples? Please advice. |
If you get WMQ.PCF to work, please let us know as I had some serious issues with it but would revisit it if you succeed.
Good luck
Ian |
|
Back to top |
|
 |
|