Author |
Message
|
lash |
Posted: Thu Nov 13, 2003 10:32 am Post subject: onException method problem |
|
|
 Apprentice
Joined: 14 May 2003 Posts: 47
|
hi friends,
i had used onException method using ExceptionListener interface.
i gave wrong queue name and trying to see whether this is working or not, but it looks like the control is not going to onException method atall.
i had put system.out.println before and after session.createqueue().
as shown below....
session = connection.createQueueSession(transacted,Session.AUTO_
ACKNOWLEDGE);
System.out.println("before queue");
queue = session.createQueue("queue name");
System.out.println("before listener2");
QReceiveExceptionListener listener2 = new QReceiveExceptionListener();
System.out.println("before set");
connection.setExceptionListener(listener2);
System.out.println("before start:");
connection.start();
receiver = session.createReceiver(queue);
-----
-------
-----------
than at the end wrote an exception listener class as below....
class QReceiveExceptionListener implements ExceptionListener
{
public void onException(JMSException je)
{
// String error = je.getLinkedException();
System.out.println("error is" +je.getLinkedException());
// System.out.println("on error class :"+error);
}
}
i could not understand where iam doing wrong, but i could not see the
system.out.println(error is....") ie the control is not coming to exception class at all.
there is not compilation errors also.
i want the logic as when ever it sees wrong queue name the control should come to exception class and i want that exception to be recorded in a file.. if the control comes to the exception class i can code some reader class in it to write to a file.
thanks in advance,
lash.
Last edited by lash on Thu Nov 13, 2003 10:54 am; edited 1 time in total |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Nov 13, 2003 10:41 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
this
Quote: |
QReceiveExceptionListener listener2 = new ReceiveExceptionListener(); |
should probably be
Quote: |
QReceiveExceptionListener listener2 = new QReceiveExceptionListener(); |
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
lash |
Posted: Thu Nov 13, 2003 10:53 am Post subject: onException method problem |
|
|
 Apprentice
Joined: 14 May 2003 Posts: 47
|
iam sorry, actually in code it is
QReceiveExceptionListener listener2 = new QReceiveExceptionListener();
when posting to site there was error. i will correct this.
so what else might be the problem for this....
thanks,
lash |
|
Back to top |
|
 |
bower5932 |
Posted: Thu Nov 13, 2003 11:13 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
I've never messed with ExceptionListeners myself. However, I'm guessing that the reason you don't get the error sent is because it is happening in the main line of your code? I thought the ExceptionListener was for errors with asynchronous (ie, onMessage()) message delivery. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Nov 13, 2003 11:17 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
bower5932 wrote: |
I've never messed with ExceptionListeners myself. However, I'm guessing that the reason you don't get the error sent is because it is happening in the main line of your code? I thought the ExceptionListener was for errors with asynchronous (ie, onMessage()) message delivery. |
I haven't messed with them either.
But looking at his code again, even if you can use ExceptionListeners in the way he's trying to, he's not assigning the ExceptionListener until AFTER the exception he's trying to catch with his listener would have occurred. That is, he's trying to catch an exception at the createQueue code, which runs BEFORE he sets the ExceptionListener. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
lash |
Posted: Thu Nov 13, 2003 12:00 pm Post subject: onException method problem |
|
|
 Apprentice
Joined: 14 May 2003 Posts: 47
|
i had checked ur replies,
now i shifted the code to before queue= session.createQueue(queue name)
but still the same problem.
thanks |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Nov 13, 2003 12:09 pm Post subject: Re: onException method problem |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
lash wrote: |
i had checked ur replies,
now i shifted the code to before queue= session.createQueue(queue name)
but still the same problem.
thanks |
Again, neither of us are sure that you CAN do what you're trying to do.
It just may not work that way, by design. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
lash |
Posted: Thu Nov 13, 2003 12:49 pm Post subject: |
|
|
 Apprentice
Joined: 14 May 2003 Posts: 47
|
in using java pdf,
chapter 4==solving problems, page 24.
java -DMQJMS_TRACE_LEVEL=base MyJMSProg
if i use above code i could get the trace date, but when i used below code for logging i could not get any thing.
java -DMQJMS_LOG_DIR=/home dir/log MyJMSProg
ihad created a log file on home directory and checked whether it wrote any thing in it or not.. but nothing is written there.
and also
i had checked in /opt/mqm/java/log===nothing there either.
if i find something there i can use
formatLog <inputfile><outputfile>===but nothing there.
what might be the problem?????
thanks in advance. |
|
Back to top |
|
 |
maxis |
Posted: Sun Nov 16, 2003 9:08 pm Post subject: |
|
|
Centurion
Joined: 25 Jun 2002 Posts: 144
|
I did read couple of answers not everything ....
here is how
works. onException works pretty much like the
method.
onMessage will be called only when message is received/arrived.. in the similar fashion onException will be called only on Exception. Having said that it'll be not be called during connecting to the queue, by giving the wrong queue name , nor while creating the session. In such instance exception will be caught on try catch block.
Now ... when does the onException gets called ... here is the answer. After creating connection if there is any problem .. like if the queue manager goes down ... then the onException will be called.
hope that helps
M |
|
Back to top |
|
 |
lash |
Posted: Tue Nov 18, 2003 12:39 pm Post subject: |
|
|
 Apprentice
Joined: 14 May 2003 Posts: 47
|
your reply looks some thing encouringing to me. definitly i will try this.
but right now my prog is running at thin client. so i dont have control of qmgr to stop. ihave to wait for them , when they r about to stop the qmgr i have to check this.
thanks for the reply,
lash. |
|
Back to top |
|
 |
|