If Camel encounters an exception it will invoke on the error handler which by default in 1.x tries to reprocess. If all that fails, the message remains unprocessed. What you need is to handle the exception yourself and process it any way you want, either delete it or move it to some other folder for review, etc.

I'd suggest looking at the try/catch: 
http://camel.apache.org/try-catch-finally.html

Cheers
Hadrian


On Jul 31, 2009, at 8:27 AM, dcheckoway wrote:


I'm using Camel Mail to route email messages to a handler.  Works
perfectly...but I've bumped into an issue whenever somebody sends an email
with an unsupported charset.  For example:

    Content-type: text/plain; charset=ansi_x3.110-1983

...and since JDK6 has no idea wtf charset that is, I get the following
exception:

Caused by: java.io.UnsupportedEncodingException: ansi_x3.110-1983
       at
sun.nio.cs.StreamDecoder.forInputStreamReader(StreamDecoder.java:52)
       at java.io.InputStreamReader.<init>(InputStreamReader.java:83)
at com.sun.mail.handlers.text_plain.getContent(text_plain.java:82)
       at
javax .activation.DataSourceDataContentHandler.getContent(DataHandler.java: 775) at javax.activation.DataHandler.getContent(DataHandler.java: 522) at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:1380)
       at
org .apache .camel .component.mail.MailBinding.extractBodyFromMail(MailBinding.java:108)

This wouldn't be such a big deal if it wasn't for the fact that Camel is now totally hosed and can't "move past" that one message in the inbox. Every time it subsequently polls the inbox, it throws that same exception and bails. It can't access any other messages at that point. I'm forced to go
in and manually delete that one message so that Camel can continue
processing the inbox.

So here are my questions...

1. Is there any way I can somehow intercept/filter the route and manually tweak the Content-Type header on the MimeMessage? I would happily munge the
charset to a known value if I could...

2. Is there any way Camel's behavior can be configured to "ignore messages
on error" or something like that?

3. Is there any way I can add Charset support for ansi_x3.110-1983? Seems
like that would be the ideal solution.

For what it's worth, here's my route:

           from("imaps://imap.gmail.com?" +
                "username=" + username +
                "&password=" + password +
                "&deleteProcessedMessages=false" +
                "&processOnlyUnseenMessages=true" +
                "&consumer.delay=10003")
               .process(handler);

Thanks in advance for your help!
--
View this message in context: 
http://www.nabble.com/Camel-Mail-issue-with-unsupported-charset-tp24755585p24755585.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Reply via email to