Author |
Message
|
BruceVanSittert |
Posted: Tue Mar 27, 2007 8:41 pm Post subject: dotNet "Error in Application" Exception |
|
|
Newbie
Joined: 27 Mar 2007 Posts: 5 Location: South Africa
|
Hi,
I'm getting a little frustrated here so if anyone can assist I would appreciate it...
I'm trying to read messages from a Websphere MQ Queue manager, this is the first time I am using MQ. I am using .Net and from the samples I've seen it should be simple.
I can Initialise the Queue Manager with no problem and I can call Access Queue to get the queue no problem. When I call Get on the Queue I get an Error in the Application Eception with a null inner exception. What I have noticed however is that if I add a watch on the Queue I can see that after I called AccessQueue all the properties on the Queue object throw the exception. So the AccessQueue method probably didn't work as expected...
I've tried messing with the names of the host etc but no matter how I do it I still get the same error...
Please help....
Code:
int iPort = int.Parse(tbPort.Text); //1414
string sChannel = tbChannel.Text; //SYSTEM.ADMIN.SVRCONN
string sQueueManager = tbQueueManager.Text; //MLKDEV00AQMGR
string sQueueName = tbQueueName.Text; //DOT.NET.TESTING.Q.A
string sHostName = tbHost.Text + "(" + iPort.ToString() + ")"; //tbHost.Text = s036mlk104003
try
{
MQQueueManager oManager = new MQQueueManager(sQueueManager, sChannel, sHostName);
MQQueue oQueue = oManager.AccessQueue(sQueueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
MQMessage oMessage = null;
MQGetMessageOptions oOpts = new MQGetMessageOptions();
oOpts.WaitInterval = 2000;
oOpts.Options |= MQC.MQGMO_WAIT;
oQueue.Get(oMessage, oOpts);
}
catch (MQException ex)
{
MessageBox.Show(ex.Message);
} |
|
Back to top |
|
 |
BruceVanSittert |
Posted: Tue Mar 27, 2007 9:25 pm Post subject: |
|
|
Newbie
Joined: 27 Mar 2007 Posts: 5 Location: South Africa
|
Ok,
So if any other fool, like me, comes along with the same error, the problem is:
MQMessage oMessage = null;
it should be:
MQMessage oMessage = new MQMessage();
I can't believe I could be so silly...
 |
|
Back to top |
|
 |
Michael Dag |
Posted: Tue Mar 27, 2007 10:25 pm Post subject: |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
BruceVanSittert wrote: |
I can't believe I could be so silly...
 |
so you are human... what is the problem  _________________ Michael
MQSystems Facebook page |
|
Back to top |
|
 |
BruceVanSittert |
Posted: Tue Mar 27, 2007 11:51 pm Post subject: |
|
|
Newbie
Joined: 27 Mar 2007 Posts: 5 Location: South Africa
|
I guess so,
The embarrasing part is that I did the same thing last week as a proof of concept to a Queue on my local PC and that time I did it right...
Thanx anyway... |
|
Back to top |
|
 |
zpat |
Posted: Wed Mar 28, 2007 12:11 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Use MQGMO_CONVERT to make the application process (MQSTR) messages from any platform (this is future proofing). |
|
Back to top |
|
 |
Vitor |
Posted: Wed Mar 28, 2007 12:26 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
BruceVanSittert wrote: |
I can't believe I could be so silly...
 |
Believe it.
I've seen silly mistakes.
I've MADE sillier mistakes.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
HubertKleinmanns |
Posted: Thu Mar 29, 2007 2:35 am Post subject: |
|
|
 Shaman
Joined: 24 Feb 2004 Posts: 732 Location: Germany
|
Vitor wrote: |
BruceVanSittert wrote: |
I can't believe I could be so silly...
 |
Believe it.
I've seen silly mistakes.
I've MADE sillier mistakes.  |
A wise guy (Lenin) said:
Quote: |
Who works, makes mistakes. Who does not make mistakes, does not work. |
 _________________ Regards
Hubert |
|
Back to top |
|
 |
BruceVanSittert |
Posted: Thu Mar 29, 2007 2:59 am Post subject: |
|
|
Newbie
Joined: 27 Mar 2007 Posts: 5 Location: South Africa
|
Quote: |
Who works, makes mistakes. Who does not make mistakes, does not work. |
I must be working really hard then...  |
|
Back to top |
|
 |
BruceVanSittert |
Posted: Thu Mar 29, 2007 5:56 am Post subject: |
|
|
Newbie
Joined: 27 Mar 2007 Posts: 5 Location: South Africa
|
Ok,
Next Question.
In dotNet, if I call Get on the Queue and there are no messages on the Queue, I get an Error: "Error in the Application".
I can't really handle this because this error could mean anything. I've tried searching through the properties on the Queue object to find something that could help but every property just throws: "Error in the Application".
How do I determine that there are no messages in the queue without just assuming that if I get that error on that line it is because there are no Messages?
Thanx, |
|
Back to top |
|
 |
Vitor |
Posted: Thu Mar 29, 2007 6:21 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
BruceVanSittert wrote: |
How do I determine that there are no messages in the queue without just assuming that if I get that error on that line it is because there are no Messages? |
You need to extract the MQ reason code from the exception. There are a raft of different codes (listed in the Application Programming Reference) that detail exactly what caused the problem.
As a starter, 2033 is the code for no messages on queue. Be aware that strictly it means "no matching messages on queue", so be careful if you're using any match options at some future point. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|