我有一个带有groovy
元素的头文件设置,如下所示:
<setHeader headerName="time_to">
<groovy>1625761488 - 3600*(properties.resolve(CamelLoopIndex)-1)</groovy>
</setHeader>
<setHeader headerName="time_from">
<groovy>1625761488 - 3600*properties.resolve(CamelLoopIndex)</groovy>
</setHeader>
但在执行路由时,我得到了如下运行时错误:
groovy.lang.MissingPropertyException: No such property: CamelLoopIndex for class: script16306769092271458244993
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:67)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:309)
at script16306769092271458244993.run(script16306769092271458244993.groovy:1)
因此,问题是如何正确访问CamelLoopIndex
?
1条答案
按热度按时间vptzau2j1#
这里正确的方法是使用
exchange.getProperty('CamelLoopIndex')
: