Java Apache Camel不使用Groovy

Java Apache Camel不使用Groovy,java,spring,apache-camel,Java,Spring,Apache Camel,我最初的问题是想使用System.currentTimeMillis()作为文件名。 Try1 {date:now:SimpleDateFormat} 不支持它。我可以用S打印毫秒,但它与前一秒不同。 Try2 尝试使用内嵌groovy dsl,但出现错误。我认为这是一种错误的方法,但我喜欢在Camel中提供内联脚本语言支持 <to uri="file://D:/Projects/?fileName=TestPipeline_$groovy{new Date()}.txt"/>

我最初的问题是想使用
System.currentTimeMillis()
作为文件名。
Try1

{date:now:SimpleDateFormat}
不支持它。我可以用
S
打印毫秒,但它与前一秒不同。
Try2 尝试使用内嵌groovy dsl,但出现错误。我认为这是一种错误的方法,但我喜欢在Camel中提供内联脚本语言支持

<to uri="file://D:/Projects/?fileName=TestPipeline_$groovy{new Date()}.txt"/>

我正在使用Camel 2.9.2,并在lib文件夹中包含Camel-groovy-2.9.2.jar。

我认为您在第三次尝试时出现了错误,因为
只允许在
中使用(可能还有其他选项)

我想试试这样的东西:

已编辑

<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"/>

新建日期().getTime()
希望这有帮助,
格格利

谢谢。我没有得到任何错误,但没有得到毫秒的时间。fileName=Test_${in.header.nowInMillis}.txt返回的Test_u${in.header.nowInMillis}.txt文件。我觉得新脚本非常好。但不知怎的,我还是得到了TestPipelline_uuz.txt。控制台上没有错误,不过.log消息也是空的!我只要说
inforoute8-//////
Invalid content was found starting with element 'groovy'. One of
<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"/>