Federico Mariani created CAMEL-24146:
----------------------------------------

             Summary: camel-saga: InMemorySagaCoordinator creates a 
FluentProducerTemplate per compensation/completion attempt and never stops it
                 Key: CAMEL-24146
                 URL: https://issues.apache.org/jira/browse/CAMEL-24146
             Project: Camel
          Issue Type: Bug
          Components: camel-core
            Reporter: Federico Mariani


h3. Problem

{{InMemorySagaCoordinator.doFinalize}} creates a new template for *every* 
endpoint invocation, including every retry 
(core/camel-support/src/main/java/org/apache/camel/saga/InMemorySagaCoordinator.java:199):

{code:java}
Exchange res = 
camelContext.createFluentProducerTemplate().to(endpoint).withExchange(target).send();
{code}

The {{CamelContext.createFluentProducerTemplate()}} javadoc is explicit: "Make 
sure to call stop() when you are done using the template, to clean up any 
resources". The template is started, carries a producer cache (default max 
1000), and is never stopped.

h3. Consequence

Every finalized saga step leaks one (or more, with retries) started service. 
Combined with the coordinator map leak this makes the in-memory saga service 
unsuitable for long-running production use.

h3. Suggested fix

Create one template per coordinator (or per saga service), reuse it for all 
finalization calls, and stop it when the coordinator/service is done.

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)

Reply via email to