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

   ## Summary
   
   _Claude Code on behalf of davsclaus_
   
   `SpringRabbitMQProducer` lazily creates its `RabbitTemplate` and 
`AsyncRabbitTemplate` without synchronization. Since a producer is a singleton 
invoked concurrently by route threads, concurrent first messages can each 
create their own template; all but the last assignment are dropped without 
being stopped. In the InOut case each racing thread also starts its template, 
so the losers are leaked in started state.
   
   ## Changes
   
   - Added a `ReentrantLock` to guard `getInOnlyTemplate()`, 
`getInOutTemplate()`, and `doStop()` — same pattern already used by 
`EndpointMessageListener.getTemplate()` in this component
   - Moved `inOutTemplate.start()` inside the null-check so it is only called 
once on creation, not on every invocation
   - Fixed `Boolean.FALSE == sent` identity comparison on a primitive boolean 
to `!sent`
   - Added `SpringRabbitMQProducerThreadSafetyTest` that verifies concurrent 
`getInOnlyTemplate()` calls from 8 threads always return the same instance
   
   Fixes: [CAMEL-24070](https://issues.apache.org/jira/browse/CAMEL-24070)
   
   ## Test plan
   
   - [x] New `SpringRabbitMQProducerThreadSafetyTest` passes — 8 threads behind 
a barrier all get the same template instance
   - [x] All existing tests pass (35 run, 4 skipped integration tests)
   - [x] Full reactor build passes


-- 
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