You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Hans Orbaan <ha...@docdata.eu> on 2015/11/05 08:28:26 UTC
RE: move to failed folder, with onException in place
Hi Claus,
I think the following test will show you what I mean. Apparently the issue only occurs with Seda.
{code}
import java.util.concurrent.TimeUnit;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
public class MoveToFailedTest extends CamelTestSupport {
@Override
public void setUp() throws Exception {
deleteDirectory("target/test");
super.setUp();
}
@Test
public void testExceptionSeda() throws Exception {
testException();
}
@Test
public void testExceptionDirect() throws Exception {
testException();
}
private void testException() throws InterruptedException {
getMockEndpoint("mock:end").expectedMessageCount(0);
getMockEndpoint("mock:errors").expectedBodiesReceived("abc");
getMockEndpoint("mock:errors").expectedFileExists("target/test/error/file.txt");
template.sendBodyAndHeader("file:target/test", "abc", Exchange.FILE_NAME, "file.txt");
this.assertMockEndpointsSatisfied(1, TimeUnit.SECONDS);
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
String errors = getTestMethodName().contains("Seda") ? "seda:errors" : "direct:errors";
// @formatter:off
from(errors).to("mock:errors");
from("file:target/test/?moveFailed=error/")
.onException(Exception.class).handled(false).to(errors).end()
.throwException(new RuntimeException("exception"))
.to("mock:end");
// @formatter:on
}
};
}
}
-----Oorspronkelijk bericht-----
Van: Claus Ibsen [mailto:claus.ibsen@gmail.com]
Verzonden: Saturday 31 October 2015 18:26
Aan: users@camel.apache.org
Onderwerp: Re: move to failed folder, with onException in place
I think you need to tell us a bit more before we can help. Maybe show a bit more route code what you attempt.
On Thu, Oct 29, 2015 at 2:28 PM, Hans Orbaan <ha...@docdata.eu> wrote:
> Hi all,
>
> Why is a file not moved to the failed folder when there is an onexception with a to-endpoint?
>
> When I use the following the file does not show up in the failed folder:
> onException(Exception.class).handled(false).to("seda:errors").end();
>
> This does work, but is obviously not of any use:
> this.onException(Exception.class).handled(false).end();
>
> This also does work, and will be my workaround:
> this.onException(Exception.class).handled(false).multicast().to("seda:
> errors").end().end();
>
> There is an earlier topic about this. Where Clause says he will log a
> ticket. Has that been done, has this been fixed?
> http://camel.465427.n5.nabble.com/Component-file-move-and-moveFailed-t
> d5685631.html
>
> I'm using 2.16.1-SNAPSHOT at the moment.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition:
https://www.manning.com/books/camel-in-action-second-edition