[
https://issues.apache.org/jira/browse/CAMEL-24150?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-24150.
---------------------------------
Resolution: Fixed
Fixed via https://github.com/apache/camel/pull/24834
> camel-saga: SagaProcessor.doStop() stops the shared CamelSagaService -
> stopping one saga route breaks sagas on all routes
> -------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24150
> URL: https://issues.apache.org/jira/browse/CAMEL-24150
> Project: Camel
> Issue Type: Bug
> Components: camel-core, eip
> Reporter: Federico Mariani
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.22.0
>
> Attachments: SagaSharedServiceRouteStopIssueTest.java
>
>
> h3. Problem
> {{SagaProcessor.doStop}} calls {{ServiceHelper.stopService(sagaService)}}
> (core/camel-core-processor/src/main/java/org/apache/camel/processor/saga/SagaProcessor.java:180-184).
> The saga service is a shared, usually context-registered service
> ({{context.addService(new InMemorySagaService())}}; {{LRASagaService}} is
> even a {{StaticService}}).
> Stopping or restarting a *single* saga route therefore stops the saga service
> for the whole CamelContext:
> * {{InMemorySagaService.doStop}} shuts down and nulls the scheduled executor
> - subsequent compensation of sagas on other routes fails with a
> {{NullPointerException}} swallowed inside the CompletableFuture chain (only a
> WARN "Cannot finalize compensation the saga" is logged) and *the compensation
> endpoint is never invoked*;
> * {{LRASagaService.doStop}} closes and nulls the shared {{LRAClient}} - NPE
> in {{newSaga}} for every other route.
> h3. Reproducer
> Attached {{SagaSharedServiceRouteStopIssueTest.java}} (goes into
> {{core/camel-core/src/test/java/org/apache/camel/processor/}}, both tests
> fail on current main):
> * {{testStoppingOneSagaRouteKeepsSharedServiceRunning}}: after
> {{stopRoute("route-a")}} the shared {{InMemorySagaService}} reports stopped;
> * {{testCompensationOnOtherRouteStillWorksAfterStoppingOneSagaRoute}}: a
> failing saga on route-b never invokes its compensation endpoint.
> h3. Suggested fix
> Do not stop the saga service from the per-route processor - starting it in
> {{doStart}} is fine (idempotent), but lifecycle/stop should be left to the
> CamelContext that owns the service (registered via {{addService}} or
> discovered from the registry).
> Found during a broader Saga EIP / camel-lra code review (July 2026).
> _Claude Code on behalf of Croway_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)