[
https://issues.apache.org/jira/browse/CAMEL-13553?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-13553:
--------------------------------
Priority: Minor (was: Major)
> OnCompletion behaves strange in combination with direct subroutes
> -----------------------------------------------------------------
>
> Key: CAMEL-13553
> URL: https://issues.apache.org/jira/browse/CAMEL-13553
> Project: Camel
> Issue Type: Bug
> Components: came-core
> Affects Versions: 2.23.2, 2.24.0
> Reporter: Jakob Thun
> Priority: Minor
> Fix For: 3.x
>
>
> There is a strange behaviour in .onCompletion().modeBeforeConsumer() when
> used in combination with direct sub-routes.
> The route behaves differently depending on where onCompletion is declared.
> When declared in the top of the route it will execute several times. Once for
> every route, including the subroutes.
> I have made a small spring-boot sample app where I try to demonstrate this
> behaviour.
> [https://github.com/jakobthun/camel-oncompletion-bug]
> This route:
> {code:java}
> public static final String ORIGINAL_ROUTE_NAME =
> "PossibleBug-original-route";
> public static final String SUBROUTE_NAME = "PossibleBug-subroute";
> public static final String DIRECT_ENDPOINT = "direct:possiblebug";
> @Override
> public void configure() throws Exception {
> from("timer:expected?period=10000&delay=5000")
> .routeId(ORIGINAL_ROUTE_NAME)
> .onCompletion().modeBeforeConsumer()
> .log("This should be done once, when the original route
> is completed i.e. after log 3. But when onCompletion is defined in top of
> route AND it is in modeBeforeConsumer() it will also be applied to when the
> direct-route is completed. So it will be executed twice.")
> .end()
> .log("1")
> .to(DIRECT_ENDPOINT)
> .log("3");
> from(DIRECT_ENDPOINT)
> .routeId(SUBROUTE_NAME)
> .log("2");
> }
> {code}
> Generates the following log:
> {noformat}
> 2019-05-21 14:50:24.545 INFO 138880 --- [imer://expected]
> PossibleBug-original-route : 1
> 2019-05-21 14:50:24.545 INFO 138880 --- [imer://expected]
> PossibleBug-subroute : 2
> 2019-05-21 14:50:24.545 INFO 138880 --- [imer://expected]
> PossibleBug-original-route : This should be done once, when the
> original route is completed i.e. after log 3. When onCompletion is defined in
> top of route it is also applied to the direct-route
> 2019-05-21 14:50:24.545 INFO 138880 --- [imer://expected]
> PossibleBug-original-route : 3
> 2019-05-21 14:50:24.545 INFO 138880 --- [imer://expected]
> PossibleBug-original-route : This should be done once, when the
> original route is completed i.e. after log 3. When onCompletion is defined in
> top of route it is also applied to the direct-route
> {noformat}
>
> As can be seen above the log message defined in onCompletion shows up twice.
> If onCompletion is defined in the end of the route this will not be the case.
> Also when using modeAfterConsumer (or not specifying mode) it will only show
> up once. See github project to see this example in action.
>
>
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)