You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Martin Lichtin <li...@yahoo.com.INVALID> on 2020/06/25 15:09:06 UTC

Camel to not lookup OSGi services when looking up a bean

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

Re: Re: Camel to not lookup OSGi services when looking up a bean

Posted by Martin Lichtin <li...@yahoo.com.INVALID>.
It's Camel 2.24.3

On 25.06.2020 17:10, Andrea Cosentino wrote:
> What is the camel version for this?
>
> Il giorno gio 25 giu 2020 alle ore 17:09 Martin Lichtin
> <li...@yahoo.com.invalid> ha scritto:
>
>> 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
>>

Re: Camel to not lookup OSGi services when looking up a bean

Posted by Andrea Cosentino <an...@gmail.com>.
What is the camel version for this?

Il giorno gio 25 giu 2020 alle ore 17:09 Martin Lichtin
<li...@yahoo.com.invalid> ha scritto:

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

Re: Re: Camel to not lookup OSGi services when looking up a bean

Posted by Martin Lichtin <li...@yahoo.com.INVALID>.
Yes that's the case currently.
OsgiDefaultCamelContext updates the registry and inserts OsgiServiceRegistry as the first registry into the list.

It would make more sense to keep the default Camel Bean registry at the head of this list.

- Martin

On 01.07.2020 11:48, Jean-Baptiste Onofre wrote:
> Ah you mean that Camel OSGi always looking for service first before falling back to bean located in the same container as the camel context (spring or blueprint) ?
>
> If so, we have to improve camel-core-osgi in the lookup to add an option defining the bean resolution order.
>
> Regards
> JB
>
>> Le 1 juil. 2020 à 11:43, Martin Lichtin <li...@yahoo.com.INVALID> a écrit :
>>
>> Hi JB
>>
>> I would, if that was the issue.
>> However in all the CamelContexts I'm only using regular beans, not calling an OSGi service.
>>
>> Ideally there should be a way to tell Camel to not look into the OSGi registry when resolving bean names. But seems hardcoded?
>>
>> - Martin
>>
>> On 29.06.2020 09:34, Jean-Baptiste Onofre wrote:
>>> 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 <li...@yahoo.com.INVALID> 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
>>>>> <li...@yahoo.com.invalid> 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
>

Re: Camel to not lookup OSGi services when looking up a bean

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Ah you mean that Camel OSGi always looking for service first before falling back to bean located in the same container as the camel context (spring or blueprint) ?

If so, we have to improve camel-core-osgi in the lookup to add an option defining the bean resolution order.

Regards
JB

> Le 1 juil. 2020 à 11:43, Martin Lichtin <li...@yahoo.com.INVALID> a écrit :
> 
> Hi JB
> 
> I would, if that was the issue.
> However in all the CamelContexts I'm only using regular beans, not calling an OSGi service.
> 
> Ideally there should be a way to tell Camel to not look into the OSGi registry when resolving bean names. But seems hardcoded?
> 
> - Martin
> 
> On 29.06.2020 09:34, Jean-Baptiste Onofre wrote:
>> 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 <li...@yahoo.com.INVALID> 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
>>>> <li...@yahoo.com.invalid> 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
>>>> 
>> 


Re: Re: Camel to not lookup OSGi services when looking up a bean

Posted by Martin Lichtin <li...@yahoo.com.INVALID>.
Hi JB

I would, if that was the issue.
However in all the CamelContexts I'm only using regular beans, not calling an OSGi service.

Ideally there should be a way to tell Camel to not look into the OSGi registry when resolving bean names. But seems hardcoded?

- Martin

On 29.06.2020 09:34, Jean-Baptiste Onofre wrote:
> 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 <li...@yahoo.com.INVALID> 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
>>> <li...@yahoo.com.invalid> 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
>>>
>

Re: Camel to not lookup OSGi services when looking up a bean

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
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 <li...@yahoo.com.INVALID> 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
>> <li...@yahoo.com.invalid> 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
>> 
>> 


Re: Re: Camel to not lookup OSGi services when looking up a bean

Posted by Martin Lichtin <li...@yahoo.com.INVALID>.
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
> <li...@yahoo.com.invalid> 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
>
>

Re: Camel to not lookup OSGi services when looking up a bean

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Caching is an option indeed. Be careful about OSGi service dynamism (to avoid side effect when the service is not there actually).

Regards
JB

> Le 27 juin 2020 à 07:59, Claus Ibsen <cl...@gmail.com> a écrit :
> 
> 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
> <li...@yahoo.com.invalid> 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
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2


Re: Camel to not lookup OSGi services when looking up a bean

Posted by Claus Ibsen <cl...@gmail.com>.
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
<li...@yahoo.com.invalid> 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



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2