简体   繁体   English

Apache Camel-Spring DSL-将String参数传递给bean方法

[英]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.

相关问题 Apache Camel Java DSL将类参数传递给bean方法 - Apache Camel Java DSL pass class parameter to bean method Spring DSL 的 Apache Camel bean 参数绑定问题 - Apache Camel bean parameter binding issue with Spring DSL 将Spring bean注入Camel DSL - Injecting Spring bean into Camel DSL 骆驼java dsl传递bean方法返回值到标头 - camel java dsl pass bean method return value to header Apache Camel Spring XML - 来自文件名表达式的 Bean 方法调用 - Apache Camel Spring XML - Bean method call from filename expression 在Java DSL上使用Java和Spring代码的Apache Camel - Apache Camel with Java and Spring Code on Java DSL 一旦目录中的所有文件都已处理完毕,Camel Spring DSL就在bean上调用方法 - Camel Spring DSL Call a method on bean once all all files in a directory have been processed 将Apache Camel示例从Spring DSL转换为Java DSL - Translating Apache Camel example from Spring DSL to Java DSL 在Apache Camel中,Java DSL与Spring DSL相比有什么优势? - What are the advantages of Java DSL over Spring DSL in Apache Camel? Is it possible to call the header value as a parameter for the method applied to the same object in simple interpreter, Spring DSL for Apache Camel? - Is it possible to call the header value as a parameter for the method applied to the same object in simple interpreter, Spring DSL for Apache Camel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM