看起来set headercurrentpage_start_time_x只被设置了一次,虽然它在循环中,但是headercurrentpage_start_time会被多次设置。下面是代码的片段,有没有人能给予我一些提示?提前感谢。
from("direct:api-query")
.loopDoWhile(simple("${in.header.continue}"))
.log(LoggingLevel.DEBUG," send to next page to \n -> {{project.query.url}}?limit={{project.query.limit}}&page=${in.header.currentPage}")
.to("metrics:timer:simple.timer?action=start")
// it will be set only once
.setHeader("currentpage_start_time_x",simple(Long.valueOf(System.currentTimeMillis()).toString()))
.process(
exg->{
LOG.info("currentpage_start_time_x->{}" , exg.getIn().getHeader("currentpage_start_time_x"));
//it will be set multiple times ( as same as loop size)
exg.getIn().setHeader("currentpage_start_time", System.currentTimeMillis());
}
)
1条答案
按热度按时间8ehkhllq1#
u use simple like a constant so这是一个固定的常数值(或对象),仅在启动路线期间设置一次,如果您希望在路线选择期间使用动态值,请不要使用此值。