[ 
https://issues.apache.org/jira/browse/CAMEL-15671?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17215623#comment-17215623
 ] 

Taras Tielkes commented on CAMEL-15671:
---------------------------------------

Claus,

Thanks for the quick follow-up on the issue.

Just writing here to confirm that your suggested work-around for Camel 2.x 
behaves as expected. For others experiencing this performance bottleneck, the 
work-around amounts to overriding the Camel {{BeanPostProcessor}} like so:
{code:java}
<camelContext id="myCamelContext" xmlns="http://camel.apache.org/schema/spring";>
   ...
</camelContext>

<bean id="myCamelContext:beanPostProcessor" 
class="org.example.camel.NullBeanPostProcessor"/>{code}
Where {{NullBeanPostProcessor}} looks like this:
{code:java}
public class NullBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) 
throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) 
throws BeansException {
        return bean;
    }
} {code}

> Performance overhead of bean post processor when using camel spring on 
> bootstrap
> --------------------------------------------------------------------------------
>
>                 Key: CAMEL-15671
>                 URL: https://issues.apache.org/jira/browse/CAMEL-15671
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-spring
>    Affects Versions: 2.25.0
>            Reporter: Taras Tielkes
>            Assignee: Claus Ibsen
>            Priority: Major
>             Fix For: 3.6.0
>
>         Attachments: image-2020-10-10-11-37-02-339.png
>
>
> We are using the \{{http://camel.apache.org/schema/spring}} namespace to 
> configure a Camel context from spring.
> It seems that 
> {{CamelNamespaceHandler.CamelContextBeanDefinitionParser#doParse}} 
> unconditionally registers a {{CamelBeanPostProcessor}} into the underlying 
> Spring {{ApplicationContext}}: there is no guard or configuration option to 
> prevent the execution of {{CamelNamespaceHandler#injectBeanPostProcessor}}.
> This is unfortunate, since we are _not_ using any of the Camel annotations in 
> the beans present in the Spring application context of our application. At 
> the same time, {{CamelBeanPostProcessor}} introduces dramatic runtime 
> performance overhead.
> Specifically, any bean initialized and configured by the Spring application 
> context will be inspected by the camel bena post processor for presence of 
> Camel annotations. In our use-case, Spring {{@Configurable}} annotated 
> entities are used, which can have bean creation rates of tens of thousands 
> per second. Without the {{CamelBeanPostProcessor}} present, the performance 
> impact of this is negligible. With the {{CamelBeanPostProcessor}} present, 
> this introduces significant bottlenecks.
> See below for the relevant parts of the Camel annotation scanning code 
> dominating this bottleneck (from a JFR recording).
> The use of the Spring Camel namespace seems to be conflated with the 
> unconditional injection of the {{CamelBeanPostProcessor}}, with no 
> configuration or strategy specialization option to separate these.
> For users using the namespace, but not using the Camel annotations, it would 
> be very useful to have control over this aspect of Camel/Spring integration.
> !image-2020-10-10-11-37-02-339.png!
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to