Reputation: 19
I'm using this clause to catch all the exceptions that happen on my project to customize its behaviour.
<onException>
<exception>java.lang.Exception</exception>
<handled><constant>true</constant></handled>
<process ref="prepareExceptionProcessor"/>
<to uri="activemq:int.sendmail" />
</onException>
Take into account that all the routes throws only java.lang.Exception in the event of an error.
The route that throws the exception is this:
<route id="int.uploadFile">
<from uri="[[toFilepath.forUpload.read]]"/>
<process ref="generateFileNameFtpProcessor"/>
<setHeader headerName="CamelFileName"><simple>[[fileName.toFtp]]</simple></setHeader>
<to id="uploadFile" uri="[[upload.toFtp]]"/>
</route>
On the test the uri "upload.toFtp" is set with a connection that doesn´t exist, so they throws an exception. The test only start the context and wait that a message insert into the queue "activemq:int.sendmail"
When I install the project on Fuse <onException>
works fine, but when I execute a test case that throws some type of exception <onException>
doesn't work.
This is the log that shows the test case when a exception is fired.
ERROR org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: 2796-1-86 on ExchangeId: 2796-1-86). Exhausted after delivery attempt: 1 caught: java.lang.Exception: Error uploading file with name 140107034802854_2_.xml.gz java.lang.Exception: Error uploading file with name 140107034802854_2_.xml.gz at au.com.inte.processor.ValidateExceptionProcessor.process(ValidateExceptionProcessor.java:22) at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.fabric.FabricTraceProcessor.process(FabricTraceProcessor.java:81) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:334) at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220) at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.Pipeline.process(Pipeline.java:117) at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150) at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117) at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73) at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:336) at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:189) at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:155) at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:142) at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) 2014-01-08 11:44:20 WARN org.apache.camel.component.file.GenericFileOnCompletion - Rollback file strategy: org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@2336bff7 for file: GenericFile[/tmp/test/work/feedsToUpload/140107034802854_2_.xml.gz]
Could you please help me find the issue?
Thanks a lot.
Upvotes: 1
Views: 956
Reputation: 340
It looks like your custom au.com.inte.processor.ValidateExceptionProcessor is throwing an exception (line 22). what does the code for this class look like? Try removing the custom processor to test if this is the issue. You can then check to see if a message ends up in your queue. Also you may/may not want to change the exception handler to catch Throwable depending on your needs. i.e:
<onException>
<exception>java.lang.Throwable</exception>
<handled><constant>true</constant></handled>
<to uri="activemq:int.sendmail" />
</onException>
Also, if you are just starting the context for your test you may need to use a mock endpoint
<onException>
<exception>java.lang.Throwable</exception>
<handled><constant>true</constant></handled>
<to uri="mock:error" />
</onException>
Upvotes: 1