[英]Apache Camel - Spring DSL - Pass String argument to bean method
On Camel 2.10.1, the following worked: 在Camel 2.10.1上,以下工作:
<camel:bean ref="profilingBean" method="addProfilingContext('TEST')"/>
The method in question takes a String parameter 有问题的方法采用String参数
Migrating to 2.10.6 , this does not work anymore, it tries to call TEST as another class. 迁移到2.10.6后,此方法不再起作用,它尝试将TEST称为另一个类。 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 干杯
The behavior/bug still exists in Camel 2.16
and also in latest 2.18.2
. 行为/错误仍然存在于
Camel 2.16
和最新的2.18.2
。
For every string constant that is passed to a bean via Spring DSL a java.lang.ClassNotFoundException
is thrown. 对于通过Spring DSL传递给bean的每个字符串常量,都会引发
java.lang.ClassNotFoundException
。 It gets more visible by setting logger for org.apache.camel.util.ObjectHelper
to TRACE
. 通过将
org.apache.camel.util.ObjectHelper
记录器设置为TRACE
它会变得更加可见。
This camel behavior also has serious negative performance impact because ClassLoader
method ( java.lang.ClassLoader.loadClass
) is synchronized for a given parameter name. 这种骆驼行为还会严重影响性能,因为
ClassLoader
方法( java.lang.ClassLoader.loadClass
)已针对给定的参数名称进行了同步。 I wrote a little demo to show this: https://github.com/groundhog2k/camel-dsl-bean-bug 我写了一个小样的演示来展示这个: https : //github.com/groundhog2k/camel-dsl-bean-bug
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.10.7或2.11.1等版本中修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.