[
https://issues.apache.org/jira/browse/CAMEL-18275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17568592#comment-17568592
]
Karen Lease commented on CAMEL-18275:
-------------------------------------
[~Gomoliako] According to the
[documentation|https://camel.apache.org/components/3.18.x/seda-component.html]
you can change this behavior with the option *waitForTaskToComplete=always.*
This is handled in the
[SedaProducer.|https://github.com/apache/camel/blob/bf06cd9533ebd0d3ed5472e4fd6bd6095f317339/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaProducer.java#L62-L66]
Using this option, all the messages in your onCompletion handlers are logged.
But this is probably not what you want. I would agree that the completions
should be executed in any case.
I believe the root cause is that the method UnitOfWork.afterRoute() finds no
Synchronizations on the UnitOfWork so the onAfterRoute() method is not called
for the Synchronizations (i.e. the completions) which were handed over and then
removed from the original UoW. This method is what updates the property
ExchangePropertyKey.ON_COMPLETION_ROUTE_IDS to remember all the routes which
have been visited by the Exchange. If this contains all the route Ids, then the
completion methods are all executed even when they are all called when the last
route is completed.
I have an idea to address this, and will submit a PR for review by Camel gurus.
> onCompletion tasks don't get executed in a pipeline with several SEDA queues
> ----------------------------------------------------------------------------
>
> Key: CAMEL-18275
> URL: https://issues.apache.org/jira/browse/CAMEL-18275
> Project: Camel
> Issue Type: Bug
> Components: came-core
> Affects Versions: 3.18.0
> Reporter: Eduard Gomoliako
> Priority: Major
>
> I stumbled upon a problem with not working {{onCompletion}} between the
> routes that pass a message over SEDA queues.
> The route configuration is similar to this simplified version:
>
> {code:java}
> from("direct:a")
> .onCompletion().log("a - done").end()
> .to("seda:b");
> from("seda:b")
> .onCompletion().log("b - done").end()
> .to("seda:c");
> from("seda:c")
> .onCompletion().log("c - done").end()
> .to("seda:d");
> from("seda:d")
> .onCompletion().log("d - done").end()
> .to("mock:end"); {code}
>
> With this configuration, I get only {{"d - done"}} logging.
> I debugged the execution and noticed that the {{onCompletion}} handler from
> "a", "b", and "c" don't get executed because they are route-scoped and get
> attempted to be executed in the scope of the next route.
> This happens because they get handed over from the initial exchange to an
> exchange prepared for the next route. It happens in the
> {{SedaProducer::addToQueue}} method with {{{}copy{}}}parameter defined as
> {{{}true{}}}, which makes the {{::prepareCopy}} method being called, which in
> its turn calls {{ExchangeHelper.createCorrelatedCopy}} with {{handover}}
> defined as {{{}true{}}}.
> It seems to me like a bug, because looking at the routes configuration I'd
> expect different behavior: all the {{onCompletion}} tasks get executed
> reporting on routes finalization. Though maybe I'm missing something here,
> and if this is the case then I would appreciate you guys helping me to find
> out the missing details.
> Here is a [unit test reproducing the
> problem|https://gist.github.com/Gems/7555776feae619ac71ed8d9dd9d4d33e].
--
This message was sent by Atlassian Jira
(v8.20.10#820010)