Claus Ibsen created CAMEL-25066:
-----------------------------------
Summary: camel-core - Producer cache eviction can stop a dynamic
endpoint that another producer cache still uses
Key: CAMEL-25066
URL: https://issues.apache.org/jira/browse/CAMEL-25066
Project: Camel
Issue Type: Improvement
Components: camel-core
Reporter: Claus Ibsen
Endpoints are shared per CamelContext, but producer caches are not. toD
resolves its URI via context.getEndpoint(uri), and the endpoint registry caches
dynamic endpoints, so two toD (or recipientList, routingSlip, ProducerTemplate)
that resolve the same URI get the same Endpoint instance. Each of them has its
own DefaultProducerCache (SendDynamicProcessor creates one per processor).
When one cache evicts its producer, ServicePool (SinglePool.cleanupEvicts)
stops the endpoint unless isEndpointInUse() finds it in the static endpoint
registry or as a route consumer. It does not know about other producer caches,
so the endpoint is stopped while another cache still holds a started producer
for it.
Example: two routes both do toD("seda:${header.region}"). Route A has a small
cacheSize and sees many regions, so it evicts seda:eu and stops that endpoint
while route B's cache still sends to it.
This is not a regression: before CAMEL-25004 the endpoint was always stopped on
eviction. Possible fixes: reference-count endpoint usage across producer
caches, or leave stopping dynamic endpoints to the endpoint registry's own
eviction.
Follow-up from the review of https://github.com/apache/camel/pull/26862.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)