Hello, > You can try with mapMailMessage=false, and then use Camel's error > handler if parsing the body / attachments of the mail fails. this would only prevent this special error, but perhaps there will others rise in the future.
> Though there was a bug in Camel when using mapMailMessage=false. You > may need to use next release of Camel and/or latest release if the bug > was fixed in that release. I worked around that and changed MailMessage in the constructor and setMessage to prevent this exception (see below), because I couldn't wait for the fix. But again this also only prevents this special exception, not others. > An alternative is to add functionality to the mail component to deal > with parsing errors before routing, such as mark it as seen or move it > etc. This would be great. How can I do that (I'm quite new to camel) or is this a new feature in a coming version? Best regards, Stefan Hof > -----Ursprüngliche Nachricht----- > Von: Claus Ibsen [mailto:claus.ib...@gmail.com] > Gesendet: Dienstag, 8. April 2014 10:58 > An: users@camel.apache.org > Betreff: Re: error blocking camel-mail consumer > > Hi > > You can try with mapMailMessage=false, and then use Camel's error > handler if parsing the body / attachments of the mail fails. > > Though there was a bug in Camel when using mapMailMessage=false. You > may need to use next release of Camel and/or latest release if the bug > was fixed in that release. > > An alternative is to add functionality to the mail component to deal > with parsing errors before routing, such as mark it as seen or move it > etc. > > On Mon, Apr 7, 2014 at 5:27 PM, <stefan....@zv-extern.fraunhofer.de> > wrote: > > Hello, > > > > if I use the mail-component for polling emails and there is an error while > consuming the mail, how can I skip this mail and move to the next? > > > > For example: > > > from("imaps://{{email.server}}?username={{email.username}}&password=R > AW({{email.password}})" > > + "&delete=true©To={{email.folder}}/done&unseen=true& > folderName={{email.folder}}" > > + "&fetchSize=1&contentType=text/html") > > moves the processed mail in the "done"-subfolder of the email-folder, if > everything is ok, eg, the route finishes. > > > > But if the mail-consumer hits an error _before_ the route starts, the error > will be logged and nothing more happens. This means, the processed mail > remains unchanged in in the email-folder and will be the next polled email, > that leads to the same error, where the error will be logged and... > > > > How can I break this endless circle an mark the email as (unsuccessfully) > processed, so that it will not be read again? > > > > Best regards, > > Stefan Hof > > > -- > Claus Ibsen > ----------------- > Red Hat, Inc. > Email: cib...@redhat.com > Twitter: davsclaus > Blog: http://davsclaus.com > Author of Camel in Action: http://www.manning.com/ibsen > Make your Camel applications look hawt, try: http://hawt.io my changes in org.apache.camel.component.mail.MailMessage: Constructor: public MailMessage(Message message) { this.originalMailMessage = this.mailMessage = message; // ----------- insert --------------------- // Workaround for server-bugs like "unable to load body<structure" // see: // http://www.oracle.com/technetwork/java/faq-135477.html#imapserverbug // Use the MimeMessage copy constructor to make a copy // of the entire message, which will fetch the entire // message from the server and parse it on the client: if (message instanceof MimeMessage) { try { this.mailMessage = new MimeMessage((MimeMessage) message); } catch (MessagingException e) { // do nothing, it's a workaround } } // ----------- end insert ----------------- } setMessage: public void setMessage(Message mailMessage) { if (this.originalMailMessage == null) { this.originalMailMessage = mailMessage; } this.mailMessage = mailMessage; // ----------- insert --------------------- // Workaround for server-bugs like "unable to load body<structure" // see: // http://www.oracle.com/technetwork/java/faq-135477.html#imapserverbug // Use the MimeMessage copy constructor to make a copy // of the entire message, which will fetch the entire // message from the server and parse it on the client: if (mailMessage.getMessageNumber() > 0 // not necessary, if new or already a copy && mailMessage instanceof MimeMessage) { try { this.mailMessage = new MimeMessage((MimeMessage) mailMessage); } catch (MessagingException e) { // do nothing, it's a workaround } } // ----------- end insert ----------------- }