You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2017/11/01 12:21:00 UTC

[jira] [Assigned] (CAMEL-11045) onCompletion does not trigger on failure if split is in route

     [ https://issues.apache.org/jira/browse/CAMEL-11045?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reassigned CAMEL-11045:
-----------------------------------

    Assignee: Claus Ibsen

> onCompletion does not trigger on failure if split is in route
> -------------------------------------------------------------
>
>                 Key: CAMEL-11045
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11045
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>            Reporter: moritz löser
>            Assignee: Claus Ibsen
>            Priority: Major
>
> I created a test to reproduce the problem:
> {code}
> import org.apache.camel.CamelExecutionException;
> import org.apache.camel.Endpoint;
> import org.apache.camel.EndpointInject;
> import org.apache.camel.RoutesBuilder;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.component.mock.MockEndpoint;
> import org.apache.camel.test.junit4.CamelTestSupport;
> import org.junit.Test;
> import java.util.Arrays;
> public class OnCompletionTest extends CamelTestSupport{
>     @EndpointInject(uri = "direct:in")
>     private Endpoint in;
>     @EndpointInject(uri = "mock:completion")
>     private MockEndpoint mockComp;
>     @EndpointInject(uri = "mock:out")
>     private MockEndpoint mockOut;
>     @Test
>     public void good() throws InterruptedException {
>         mockComp.setExpectedMessageCount(1);
>         mockOut.setExpectedMessageCount(2);
>         //
>         context.createProducerTemplate().sendBody(in, Arrays.asList("1","2"));
>         //
>         assertMockEndpointsSatisfied();
>     }
>     @Test
>     public void exception() throws InterruptedException {
>         mockComp.setExpectedMessageCount(1);
>         mockOut.setExpectedMessageCount(2);
>         //
>         mockOut.whenAnyExchangeReceived(exchange -> {throw new IllegalArgumentException("");});
>         try {
>             context.createProducerTemplate().sendBody(in, Arrays.asList("1","2"));
>             fail();
>         } catch (CamelExecutionException e){
>         }
>         //
>         mockOut.assertIsSatisfied();
>         mockComp.assertIsSatisfied();
>     }
>     @Override
>     public boolean isUseRouteBuilder() {
>         return true;
>     }
>     @Override
>     protected RoutesBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 // @formatter:off
>                 from(in)
>                         .onCompletion().to(mockComp).end()
>                         .split().body()
>                             //.stopOnException()
>                             //.shareUnitOfWork()
>                 .to(mockOut)
>                 ;
>                 // @formatter:on
>             }
>         };
>     }
> }
> {code}
> I would expect that both tests pass. In case of exception the onCompletion is not triggered. Documentation says it should trigger in all cases. "onFailureOnly()" doesn't help either. I also tried "stopOnException()" and "shareUnitOfWork()" in some combinations with no avail.
> If this works as intended there should be at least a hint in the documentation.
> For the sake of completeness i also asked here for a solution/ workaround: http://stackoverflow.com/questions/42928208/camel-oncompletion-not-working-on-exception-after-a-split-bug



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)