Resolution: Won't Fix
Affects Version/s: None
Fix Version/s: None
I have a case where one bundle/blueprint-container defines:
and another one defines Camel context with:
The problem is that when bundle defining messageIdRepositoryImpl is stopped, stopping bundle/blueprint-container with camel context that references messageIdRepositoryImpl leads to wait on Proxy/ReferenceRecipe:
There are few problems here. First - GenericFileEndpoint.doStart() does this:
which adds the blueprint recipe (proxy) to org.apache.camel.impl.DefaultCamelContext#servicesToStop without a way to specify stopOnShutdown=false.
IMO services obtained from OSGi registry should not be tied to lifecycle of single context with route having #referenceToOsgiOrBlueprintService in endpoint URI.
Also - the above stack trace is not retrieved when stopping an osgi service, but when log.warning an exception!:
In the above code we have implicit toString() call on service which leads to another proxy call which calls org.apache.aries.blueprint.container.ReferenceRecipe.ServiceDispatcher#call() → org.apache.aries.blueprint.container.ReferenceRecipe#getService() → org.apache.aries.blueprint.container.ReferenceRecipe#monitor.wait(metadata.getTimeout().
The most obvious fix is to move idempotent repository to a blueprint file where file endpoint is used.
But as OSGi devil's advocate, I suggest more generic solution: when looking up objects inside org.apache.camel.blueprint.BlueprintContainerRegistry, in addition to calling org.osgi.service.blueprint.container.BlueprintContainer#getComponentInstance() we may check if blueprintContainer.getComponentMetadata(name) instanceof ReferenceMetadata and in such case return a proxied proxy that would prevent waiting for blueprint reference when we're stopping the context - we'd have to check if the target service is available anyway (why ReferenceRecipe doesn't have a method like "tryGetService()"?)...
Less generic fix could be to add a flag used instead of default:
so user could decide whether idempotent repository is or isn't "external" ("shared").