[英]Apache Camel - Groovy Scripting
我正在嘗試在Spring DSL中使用Groovy腳本,如下所示:
<from uri="file://{{my.path}}">
<choice>
<when>
<groovy>properties.resolve 'file.one.isActive' == 'true'</groovy>
<to uri="file://{{file.one}}"/>
</when>
<otherwise>
<to uri="file://{{file.two}}"/>
</otherwise>
</choice>
</from>
但是我得到以下異常:
Exhausted after delivery attempt:
1 caught: groovy.lang.MissingMethodException:
No signature of method: java.util.LinkedHashMap.resolve()
is applicable for argument types:
(java.lang.Boolean) values: [false]
我的pom.xml中有以下依賴項:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-script</artifactId>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-groovy</artifactId>
<version>2.13.1</version>
</dependency>
基於http://camel.apache.org/groovy.html
我應該能夠將properties
引用與resolve
方法一起使用。
知道有什么問題嗎?
我認為它正在解決('file.one.isActive'=='true')。 為了清晰起見,更好地解析( 'file.one.isActive' ) =='true'
我遇到了同樣的問題,因此為將來會遇到的其他人發布解決方案。
盡管駱駝文檔中有信息說腳本上下文已使用org.apache.camel.builder.script.PropertiesFunction類型的properties屬性進行了預配置,但這種情況並未發生。 屬性屬性解析為交換屬性。 似乎是Camel缺陷(使用Camel 2.16.1)。
解決方法:
camelContext.resolvePropertyPlaceholders("{{file.one.isActive}}")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.