camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAMEL-11045) onCompletion does not trigger on failure if split is in route
Date Wed, 01 Nov 2017 12:34:00 GMT

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

Claus Ibsen updated CAMEL-11045:
--------------------------------
    Fix Version/s: 2.21.0
                   2.20.1
                   2.19.4

> 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
>             Fix For: 2.19.4, 2.20.1, 2.21.0
>
>
> 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)

Mime
View raw message