On Mon, Aug 3, 2009 at 4:16 AM, Willem Jiang<[email protected]> wrote:
> Hi,
>
> Current Camel Error handler only works for the checking the error which is
> thrown between the route's endpoints.
>
> Your UTFDataFormatException is thrown when the Message is created to be
> routed into the pipeline, I don't think the camel error handler can catch
> this kind of error.
>
Yes the Camel error handling is based on message exchanges and not on
initial transport issues.
You can / should remedy this with AMQ as its has a poison message. And
must have means to be able to deal with it in AMQ.
> Maybe we need to do some enhancement on the JMSComponent to let it create a
> message with exception when it create the camel message from the JMS
> message, then camel error handle will check it when this message is routing
> to the other endpoint.
>
Yeah its kinda a trade off whether Camel should be able to create an
artificial message and set the caused exception on it
to allow Camel to handle the exception.
But what if the exception was some remote connection exception and not
as in this case some JMS payload issues.
Its kinda hard to do this well and generic for all components.
> Willem
>
> Ensonik wrote:
>>
>> Hi all,
>>
>> We currently have a problem where messages that can't be read properly get
>> dropped instead of being put into a dlq. I have an errorHandler that works
>> properly when the exception is thrown from within the route (from a
>> processor for example), but refuses to kick in when it's a lower level
>> error
>> (i.e.: Before even getting into the route).
>>
>> - I'm using camel-2.0-M1
>> - The route is setup through the Java dsl
>>
>> The route looks something like:
>> errorHandler(
>> deadLetterChannel(configuration.getDLQCompomentUrl()).
>> maximumRedeliveries(configuration.getMaxRedeliveries()).
>> log(RTSListenerRouteBuilder.class).
>> retriesExhaustedLogLevel(LoggingLevel.ERROR).
>> retryAttemptedLogLevel(LoggingLevel.TRACE)
>> );
>>
>> from(configuration.getSourceComponentUrl()).
>> choice().
>> when(configuration.getMessageFilter()).
>> process(configuration.getMessageEnricher()).
>> to(configuration.getMessageEndpoint()).
>> otherwise().
>> to(configuration.getInvalidMessageComponentUrl());
>>
>> Pretty straightforward ... I've tried adding a few variants, most notable
>> adding a global exception handler:
>>
>>
>> onException(java.io.UTFDataFormatException.class).handled(false).to("jms.mydlq");
>>
>> To no avail.
>>
>> Here's the stack trace I get:
>> [WARN] [org.springframework.jms.listener.DefaultMessageListenerContainer]
>> Execution of JMS message listener failed
>> org.apache.camel.RuntimeCamelException: Failed to extract body due to:
>> javax.jms.JMSException: java.io.UTFDataFormatException. Message:
>> ActiveMQTextMessage {...l}
>> at
>>
>> org.apache.camel.component.jms.JmsBinding.extractBodyFromJms(JmsBinding.java:104)
>> at
>> org.apache.camel.component.jms.JmsMessage.createBody(JmsMessage.java:150)
>> at
>> org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:45)
>> at
>> org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:52)
>> at
>>
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:74)
>> at
>>
>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
>> at
>>
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>> at
>>
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:65)
>> at
>>
>> org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:72)
>> at
>>
>> org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:543)
>> at
>>
>> org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:482)
>> at
>>
>> org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:451)
>> at
>>
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
>> at
>>
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
>> at
>>
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
>> at
>>
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:881)
>> at java.lang.Thread.run(Thread.java:613)
>> Caused by: javax.jms.JMSException: java.io.UTFDataFormatException
>> at
>>
>> org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
>> at
>>
>> org.apache.activemq.command.ActiveMQTextMessage.getText(ActiveMQTextMessage.java:91)
>> at
>>
>> org.apache.camel.component.jms.JmsBinding.extractBodyFromJms(JmsBinding.java:93)
>> ... 16 more
>> Caused by: java.io.UTFDataFormatException
>> at
>>
>> org.apache.activemq.util.MarshallingSupport.readUTF8(MarshallingSupport.java:372)
>> at
>>
>> org.apache.activemq.command.ActiveMQTextMessage.getText(ActiveMQTextMessage.java:86)
>> ... 17 more
>>
>>
>>
>> Thanks for any input.
>>
>
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus