Hi Martin,

What about implementing a caching service as proxy in front of your bean ?
It’s pretty easy with Karaf (and you have a caching service on demand).
So, the Camel Route will always request the bean, but the bean logic can be 
cached.

Thoughts ?

Regards
JB

> Le 29 juin 2020 à 09:29, Martin Lichtin <[email protected]> a écrit :
> 
> Thanks.
> Unfortunately the cache does not seem to kick in.
> Also it's supposed to be turned on by default (xsd: "Caches the bean lookup, 
> to avoid lookup up bean on every usage. Default value: true".
> 
> The bean is called from a REST CamelContext configured such as
> 
>     <rest path="/mypath">
>       <get outType="myType">
>         <route>
>           <to uri="bean:myBean?cache=true&amp;method=myMethod()" />
>         </route>
>       </get>
> 
> I don't see this bean lookup behaviour for "normal" CamelContexts, so caching 
> seems to work, but not in this case here.
> 
> - Martin
> 
> On 27.06.2020 07:59, Claus Ibsen wrote:
>> You can cache the bean so the lookup is only done once.
>> 
>> to("bean:foo?cache=true")
>> 
>> In Camel 3.x there is a new scope option instead
>> 
>> On Thu, Jun 25, 2020 at 5:09 PM Martin Lichtin
>> <[email protected]> wrote:
>>> Is there a way to tell Camel to not search OSGi services when looking up a 
>>> bean?
>>> 
>>> It seems by default it's continuously looking up the service references, 
>>> would like to turn this off.
>>> 
>>> Stack Trace    Sample Count    Percentage(%)
>>> java.util.TreeMap.getEntryUsingComparator(Object)    17    3.753
>>>     java.util.TreeMap.getEntry(Object)    17    3.753
>>>        java.util.TreeMap.get(Object)    17    3.753
>>> org.apache.felix.framework.ServiceRegistrationImpl.getProperty(String) 11   
>>>  2.428
>>> org.apache.felix.framework.ServiceRegistrationImpl$ServiceReferenceMap.get(Object)
>>>  11    2.428
>>> org.apache.felix.framework.capabilityset.CapabilitySet.match(Set, 
>>> SimpleFilter)    11    2.428
>>> org.apache.felix.framework.capabilityset.CapabilitySet.match(SimpleFilter, 
>>> boolean)    9    1.987
>>> org.apache.felix.framework.ServiceRegistry.getServiceReferences(String, 
>>> SimpleFilter)    9    1.987
>>> org.apache.felix.framework.Felix.getServiceReferences(BundleImpl, String, 
>>> String, boolean)    9    1.987
>>> org.apache.felix.framework.Felix.getAllowedServiceReferences(BundleImpl, 
>>> String, String, boolean)    9    1.987
>>> org.apache.felix.framework.BundleContextImpl.getServiceReferences(String, 
>>> String)    9    1.987
>>> org.apache.camel.core.osgi.OsgiServiceRegistry.lookupByName(String) 9    
>>> 1.987
>>> org.apache.camel.impl.CompositeRegistry.lookupByName(String)    9 1.987
>>> org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookupByName(String)
>>>  9    1.987
>>> org.apache.camel.component.bean.RegistryBean.lookupBean()    9 1.987
>>> org.apache.camel.component.bean.RegistryBean.getBean()    9    1.987
>>> org.apache.camel.component.bean.AbstractBeanProcessor.process(Exchange, 
>>> AsyncCallback)    9    1.987
>>> org.apache.camel.component.bean.BeanProcessor.process(Exchange, 
>>> AsyncCallback)    9    1.987
>>> org.apache.camel.component.bean.BeanProducer.process(Exchange, 
>>> AsyncCallback)    9    1.987
>>> org.apache.camel.processor.SendProcessor.process(Exchange, AsyncCallback)   
>>>  9    1.987
>>> org.apache.camel.processor.RedeliveryErrorHandler.process(Exchange, 
>>> AsyncCallback)    9    1.987
>>> org.apache.camel.processor.CamelInternalProcessor.process(Exchange, 
>>> AsyncCallback)    9    1.987
>>> org.apache.camel.processor.CamelInternalProcessor.process(Exchange, 
>>> AsyncCallback)    9    1.987
>>> org.apache.camel.processor.DelegateAsyncProcessor.process(Exchange) 9    
>>> 1.987
>>> org.apache.camel.http.common.CamelServlet.doService(HttpServletRequest, 
>>> HttpServletResponse)    9    1.987
>>> 
>>> - Martin
>> 
>> 

Reply via email to