You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Willem Jiang <wi...@gmail.com> on 2009/08/03 04:16:31 UTC

Re: Dropped jms messages on java.io.UTFDataFormatException

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.

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.

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.
> 		


Re: Dropped jms messages on java.io.UTFDataFormatException

Posted by Ensonik <mi...@streamtheworld.com>.
Thanks for the input. I'll see what I can do about dealing with it in AMQ
directly.



Claus Ibsen-2 wrote:
> 
> On Mon, Aug 3, 2009 at 4:16 AM, Willem Jiang<wi...@gmail.com>
> 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
> 
> 

-- 
View this message in context: http://www.nabble.com/Dropped-jms-messages-on-java.io.UTFDataFormatException-tp24761350p24811014.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Dropped jms messages on java.io.UTFDataFormatException

Posted by Claus Ibsen <cl...@gmail.com>.
Try using AMQ redeliver handling and its DLQ
http://activemq.apache.org/message-redelivery-and-dlq-handling.html
http://activemq.apache.org/redelivery-policy.html

Then when you message fails X number of times AMQ should be able to
move it to a DLQ



On Tue, Aug 4, 2009 at 6:05 PM, Ensonik<mi...@streamtheworld.com> wrote:
>
> Actually, I'm struggling to understand what you're suggesting. All my JMS
> interaction is done through Camel right now. I need to hook and get access
> to that message outside of Camel ...
>
> So if I get it right, I'll need to have some sort of consumer (which doesn't
> use Camel) on my queue which will check the payload, then once it's
> confirmed as right, move to a queue where Camel is listening?
>
> Do you see the irony? I'm guessing that it's not what you're suggesting, but
> right now, that's all I can see. Dropping messages is not an option for me
> (as I'm guessing is the case for many).
>
>
> Claus Ibsen-2 wrote:
>>
>> On Mon, Aug 3, 2009 at 4:16 AM, Willem Jiang<wi...@gmail.com>
>> wrote:
>> 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.
>>
>
> --
> View this message in context: http://www.nabble.com/Dropped-jms-messages-on-java.io.UTFDataFormatException-tp24761350p24811480.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Dropped jms messages on java.io.UTFDataFormatException

Posted by Ensonik <mi...@streamtheworld.com>.
Actually, I'm struggling to understand what you're suggesting. All my JMS
interaction is done through Camel right now. I need to hook and get access
to that message outside of Camel ...

So if I get it right, I'll need to have some sort of consumer (which doesn't
use Camel) on my queue which will check the payload, then once it's
confirmed as right, move to a queue where Camel is listening?  

Do you see the irony? I'm guessing that it's not what you're suggesting, but
right now, that's all I can see. Dropping messages is not an option for me
(as I'm guessing is the case for many).


Claus Ibsen-2 wrote:
> 
> On Mon, Aug 3, 2009 at 4:16 AM, Willem Jiang<wi...@gmail.com>
> wrote:
> 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.
> 

-- 
View this message in context: http://www.nabble.com/Dropped-jms-messages-on-java.io.UTFDataFormatException-tp24761350p24811480.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Dropped jms messages on java.io.UTFDataFormatException

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 3, 2009 at 4:16 AM, Willem Jiang<wi...@gmail.com> 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