You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Olaf <om...@gmail.com> on 2014/03/20 16:43:06 UTC

move files if message fails

Hello,

In my route below I'd like to move only a successfully processed file into
'done' folder. If any exception occurs or message is routed to dead letter
channel I want to move the input file into failed folder. I've used
&moveFailed=failed option, but it does not work. The file is just moved to
'done' folder even if NullPointerException happens in beanRef("processor1",
"step2") part of the route. 

Thanks for help!

@Override
public void configure() throws Exception {

    errorHandler(deadLetterChannel(direct:dead));
    onException(IOException.class)
        .handled(true).maximumRedeliveries(10)
        .retryAttemptedLogLevel(LoggingLevel.WARN).redeliveryDelay(10000)
        .to(direct:dead);

   
from(file:incoming?preMove=inprogress&move=done/${date:now:yyyy-MM-dd}/${file:name}&moveFailed=failed)
        .beanRef("processor1", "step1")
        .beanRef("processor1", "step2")
        .to("log:done");
}



--
View this message in context: http://camel.465427.n5.nabble.com/move-files-if-message-fails-tp5749154.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: move files if message fails

Posted by Olaf <om...@gmail.com>.
Thank you very much! 

I need deadLetterChannel, because of custom error logging logic, which saves
message with all errors into db. I think I have to do the following:

onException(IOException.class) 
    .handled(true).maximumRedeliveries(10) 
    .retryAttemptedLogLevel(LoggingLevel.WARN).redeliveryDelay(10000) 
    .to(direct:dead); 
onException(Exception.class).to(direct:dead);

and then log in from(direct:dead)



--
View this message in context: http://camel.465427.n5.nabble.com/move-files-if-message-fails-tp5749154p5749156.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: move files if message fails

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

This is expected as your DLC handles the exception.

So remove that, or do not use it in the file route.
You can still use onException to tell Camel to retry up till 10 times.
And if its still a problem then the exchange is failed, and the file
consumer will use the moveFailed.

On Thu, Mar 20, 2014 at 4:43 PM, Olaf <om...@gmail.com> wrote:
> Hello,
>
> In my route below I'd like to move only a successfully processed file into
> 'done' folder. If any exception occurs or message is routed to dead letter
> channel I want to move the input file into failed folder. I've used
> &moveFailed=failed option, but it does not work. The file is just moved to
> 'done' folder even if NullPointerException happens in beanRef("processor1",
> "step2") part of the route.
>
> Thanks for help!
>
> @Override
> public void configure() throws Exception {
>
>     errorHandler(deadLetterChannel(direct:dead));
>     onException(IOException.class)
>         .handled(true).maximumRedeliveries(10)
>         .retryAttemptedLogLevel(LoggingLevel.WARN).redeliveryDelay(10000)
>         .to(direct:dead);
>
>
> from(file:incoming?preMove=inprogress&move=done/${date:now:yyyy-MM-dd}/${file:name}&moveFailed=failed)
>         .beanRef("processor1", "step1")
>         .beanRef("processor1", "step2")
>         .to("log:done");
> }
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/move-files-if-message-fails-tp5749154.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@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