[英]Apache Camel not working with Groovy
My original issue is that I want to use System.currentTimeMillis()
as fileName. 我最初的问题是我想使用System.currentTimeMillis()
作为fileName。
Try1 尝试1
{date:now:SimpleDateFormat}
does not support it. 不支持。 I can print Milliseconds with S
but its difference from the previous second. 我可以用S
打印毫秒,但与前一秒的区别。
Try2 Tried using inline groovy dsl but got error. Try2尝试使用内嵌groovy dsl,但出现错误。 I think this was a wrong approach but I love to have inline Scripting language support in Camel 我认为这是错误的方法,但我喜欢在Camel中提供内联脚本语言支持
<to uri="file://D:/Projects/?fileName=TestPipeline_$groovy{new Date()}.txt"/>
Try 3 Now I have lowered my expectation and thought to use groove straight forward. 尝试3现在,我降低了期望,并考虑直接使用凹槽。 As a first pass tried Sping DSL example by just writing 作为第一步,通过编写Sping DSL 示例进行了尝试
<groovy>new Date()</groovy>
But application context doesn't recognize groovy
tag. 但是应用程序上下文无法识别groovy
标签。
Invalid content was found starting with element 'groovy'. One of
I am using Camel 2.9.2 and included camel-groovy-2.9.2.jar in lib folder. 我正在使用骆驼2.9.2,并在lib文件夹中包含camel-groovy-2.9.2.jar。
I think you have the error on your 3rd try because <groovy>
is only allowed in <translate>
<setBody>
or <setHeader>
(there might be other options). 我认为您在第三次尝试时遇到了错误,因为<groovy>
仅在<translate>
<setBody>
或<setHeader>
被允许(可能还有其他选项)。
I'd try something like: 我会尝试类似的东西:
edited 已编辑
<setHeader headerName="nowInMillis">
<groovy>new Date().getTime()</groovy>
</setHeader>
<log message="/////////////// ${in.header.nowInMillis}" loggingLevel="INFO"/>
<to uri="file://D:/Projects/?fileName=TestPipeline_${in.header.nowInMillis}.txt"/>
Hope this helps, Gergely 希望这对您有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.