Apache Camel - Spring DSL - Pass String argument to bean method

天大地大妈咪最大 提交于 2020-02-06 04:32:13

问题


On Camel 2.10.1, the following worked:

<camel:bean ref="profilingBean" method="addProfilingContext('TEST')"/>

The method in question takes a String parameter

Migrating to 2.10.6 , this does not work anymore, it tries to call TEST as another class. I have tried wrapping with ${} , trying to use exotic combinations of "& quot;" etc...

The only solution I found was to put the value in a header using constant language then call the header using simple. Obviously, this isn't very clean...

Do you have any ideas how to do this?

Cheers


回答1:


Your solution with the header is fine. The bug you talk about should be fixed in 2.10.7, or 2.11.1 etc.




回答2:


The behavior/bug still exists in Camel 2.16 and also in latest 2.18.2.

For every string constant that is passed to a bean via Spring DSL a java.lang.ClassNotFoundException is thrown. It gets more visible by setting logger for org.apache.camel.util.ObjectHelper to TRACE.

This camel behavior also has serious negative performance impact because ClassLoader method (java.lang.ClassLoader.loadClass) is synchronized for a given parameter name. I wrote a little demo to show this: https://github.com/groundhog2k/camel-dsl-bean-bug



来源:https://stackoverflow.com/questions/18788241/apache-camel-spring-dsl-pass-string-argument-to-bean-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!