davsclaus opened a new pull request, #24830:
URL: https://github.com/apache/camel/pull/24830

   ## Summary
   
   _Claude Code on behalf of davsclaus_
   
   `InMemorySagaCoordinator.doFinalize` created a new `FluentProducerTemplate` 
per compensation/completion call (including retries) and never stopped it. Each 
leaked template holds a started `ProducerTemplate` with a producer cache 
(default max 1000). With the default 5 retry attempts, a single saga 
finalization could leak up to N*5 templates.
   
   **Fix:** Create a shared `ProducerTemplate` in `InMemorySagaService` (which 
already has `doStart`/`doStop` lifecycle) and reuse it across all coordinator 
finalization calls. The `FluentProducerTemplate` was overkill here — the only 
call was `.to(endpoint).withExchange(target).send()`, which delegates to 
`ProducerTemplate.send(Endpoint, Exchange)`.
   
   Changes:
   - `InMemorySagaService`: add a `ProducerTemplate` field, create in 
`doStart()`, stop in `doStop()`
   - `InMemorySagaCoordinator`: replace per-call 
`createFluentProducerTemplate()` with the shared 
`sagaService.getProducerTemplate().send()`
   
   ## Test plan
   
   - [x] All 24 existing saga tests pass (`SagaTest`, `SagaFailuresTest`, 
`SagaOptionsTest`, `SagaPropagationTest`, `SagaRemoveHeadersTest`, 
`SagaTimeoutTest`, `SagaComponentTest`)
   - [x] `SagaFailuresTest` exercises the retry code path where the leak was 
most severe
   
   Co-Authored-By: Claude Opus 4.6 <[email protected]>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to