如何将日期动态添加到骆驼路线 xml 'to uri' [英] How to add date dynamically to camel route xml 'to uri'

查看:26
本文介绍了如何将日期动态添加到骆驼路线 xml 'to uri'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在添加新的骆驼路线 xml.我无法将日期值输入到 URI.

</路线>

当我像上面一样使用它时,得到 CaughtExceptionType: groovy.lang.MissingPropertyException, CaughtExceptionMessage: No such property: yyyy for class: script1465913927580309309860, StackTrace: groovy.lang.MissingPropertyException: No such property: No such property: yyyy: script1465913927580309309860, StackTrace: groovy.lang.MissingPropertyException: No such property: No such property: yyyy905903085903059059090901>

在 URI 中,我提到了 yyyy-MM-dd 格式的文件夹名称.我不知道如何在那里获取日期.简而言之,我想将 uri 设为C:/myWork/2011-01-01".我想到的问题是因为 groovy 解析to uri"值提前致谢.

解决方案

使用动态路由.使用 <toD uri="/path/to/file/${date:now:yyyy-MM-dd}"> 以便根据运行时值动态路由

I am adding new camel route xml. I am having trouble getting date value in to to URI.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<route xmlns="http://www.myCompany.com/123/api/route/1.0">
//...some lines
....

<from>
<uri>...</uri>
  ....
.....
</from>
<to>
  <uri>file://C:/mywork/${date:now:yyyy}-${date:now:MM}-${date:now:dd}</uri>
</to>
</route>

When I use this as above getting CaughtExceptionType: groovy.lang.MissingPropertyException, CaughtExceptionMessage: No such property: yyyy for class: script1465913927580309309860, StackTrace: groovy.lang.MissingPropertyException: No such property: yyyy for class: script1465913927580309309860

In to URI I have mentioned the folder name with yyyy-MM-dd format.I do not know how to get date there. In short I want to uri as 'C:/myWork/2011-01-01'. THe problem I am thinking of is because of groovy parsing the 'to uri' value Thanks in advance.

解决方案

use dynamic routing. Use <toD uri="/path/to/file/${date:now:yyyy-MM-dd}"> in order to dynamically route based on run time values

这篇关于如何将日期动态添加到骆驼路线 xml 'to uri'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆