Thanks Claus. So I could get the Route starting by specifying the JMS endpoint 
like (note the hash):

from("jms:"+getRequestQueue()+getRequestQueueOps()+"&exceptionListener=#jmsExceptionListener")

So that when Camel starts I can see the following in the logs:

Route: JmsRouter started and consuming from: 
Endpoint[jms://CBS.ASYNC?exceptionListener=%23jmsExceptionListener&replyTo=CBS.REPLY.NSYNC]

However when I cause the exception with the Queue missing, this 
ExceptionListener is never hit and Camel goes into the infinite loop with the 
MQJMS2008 error.

I can't see an example of ExceptionListener. The JMS tests that have exception 
handling (eg. JMSValidatorTest, ActiveMQ HighVolume) use doTry and doCatch. 
However these won't work in this case as the doTry would have to be outside the 
first "from" (which is the JMS endpoint).

Is there a better way to handle these types of "missing resource" exceptions? 
Why does Camel go into this loop? I assume it is because it is rolling the 
message back to the source queue and trying again. This being the case how can 
I prevent this from happening?

Thanks,

Damian.



-----Original Message-----
From: Claus Ibsen [mailto:[email protected]]
Sent: Tuesday, 14 December 2010 6:04 PM
To: [email protected]
Subject: Re: JMS Exceptions

A good idea is to check the unit test of camel-jms and search for 
exceptionListener to see how to use this option.

You need to refer to a bean id which it will lookup in the spring xml file.

exceptionListener=foo

<bean id="foo" class="..."/>


On Tue, Dec 14, 2010 at 5:28 AM, Damian Harvey <[email protected]> wrote:
> I had an error in a property file with an incorrect queue name that didn't 
> exist. When the JMS Reply was hit a JMSException was generated "MQJMS2008: 
> failed to open MQ queue". This is to be expected. What happens is that Camel 
> goes into an infinite loop trying to process the message.
>
> I was expecting my onException in the Route would handle it but it did not. I 
> have tried to add an ExceptionListener that "is to be notified of any 
> underlying JMS exceptions"  however I think I have the syntax wrong. Here is 
> a simplified version of my route:
>
> public void configure() throws Exception {
>                getContext().setHandleFault(true);
>
> onException(JmsException.class).handled(true).to("jms:SYSTEM.DEAD.LETT
> ER.QUEUE");
>
> errorHandler(deadLetterChannel("jms:SYSTEM.DEAD.LETTER.QUEUE"));
>
>
> from("jms:CBS.START?replyTo=CBS.REPLY&exceptionListener=com.aon.camel.
> exception.ExceptionListener")
>                .process(new JmsInboundMessageProcessor())
>
> .recipientList(simple("${header.requestNode}")).ignoreInvalidEndpoints
> ()
>                .process(new JmsOutboundMessageProcessor()); }
>
> Thanks,
>
> Damian.
>
> ________________________________
>
> This communication (and any attachments) is directed in confidence to the 
> addressee(s) listed above, and may not otherwise be distributed, copied or 
> used. The contents of this communication may also be subject to privilege, 
> and all rights to that privilege are expressly claimed and not waived. If you 
> have received this communication in error, please notify us by reply e-mail 
> or by telephone and delete this communication (and any attachments) without 
> making a copy.
>
> Before opening or using attachments, you should check them for viruses and 
> defects. We do not accept liability in connection with computer virus, data 
> corruption, delay, interruption, unauthorised access or unauthorised 
> amendment.
>



--
Claus Ibsen
-----------------
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/


This communication (and any attachments) is directed in confidence to the 
addressee(s) listed above, and may not otherwise be distributed, copied or 
used. The contents of this communication may also be subject to privilege, and 
all rights to that privilege are expressly claimed and not waived. If you have 
received this communication in error, please notify us by reply e-mail or by 
telephone and delete this communication (and any attachments) without making a 
copy.

Before opening or using attachments, you should check them for viruses and 
defects. We do not accept liability in connection with computer virus, data 
corruption, delay, interruption, unauthorised access or unauthorised amendment.

Reply via email to