我有一个Camel路线,看起来像这样:
public class CamelReaderRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("quartz://myjob?cron=0+0/5+*+*+*+?")
//....(some more content)
.routeId("MyCamelRoute");
}
Run Code Online (Sandbox Code Playgroud)
基本上Quartz每五分钟"触发"一次路线.单位测试此路线时,除非时间恰好是00:00或00:05或00:10,否则不会开火等等.
那么如何更改"from"中使用的端点,以便路由立即触发?到目前为止,这是我的测试类:
public class CamelRouteTest extends CamelTestSupport {
@Test
public void shall_run_the_route_or_something() {
context.getRouteDefinition("MyCamelRoute")
.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
//something should be done here?
}
});
Run Code Online (Sandbox Code Playgroud)
我可以看到在Camel 2.9中我可以在我的configure方法中使用replaceFromWith,但由于依赖性等等,我坚持使用Camel 2.8.他们在2.9之前有过任何形式的replaceFromWith吗?
一些选项,一个是设置石英"fireNow = true"选项,以便在路由开始时调用(尽管它也会在部署时执行).否则,只需打破石英路线,即可直接调用处理...
from("quartz://myjob?cron=0+0/5+*+*+*+?")
.to("direct:process");
from("direct:process")...
Run Code Online (Sandbox Code Playgroud)
然后在你的单元测试中...调用直接路由等.
template.sendBody("direct:process",null);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3397 次 |
| 最近记录: |