2015-07-10 72 views
1

我正在开发消息路由器的过程中,部分设计是根据控制路由中放置的某些文件命令停止/暂停和启动/恢复路由。挂起的骆驼路由报告没有中止

我试图遵循骆驼建议,以支持暂停/恢复路线作为停止/启动它的替代方案。

我的履历逻辑取决于某些路线的状态,说我有两条路线ABC和XYZ不能同时活动。为了促进这一点,我的控制路线支持两个命令SUSPEND <route id> and RESUME <route id>。所以简而言之,如果路线ABC没有被暂停,那么RESUME XYZ将不会执行任何操作。

我的单元测试(使用JMockit)通过了OK。然而,当运行实际应用程序时,我可以看到即使我之前暂停了路线ABC,路线XYZ也不会恢复。

我放了一些日志条目,令我惊讶的是,在执行route.suspend("ABC")后,显然成功地给出了骆驼日志条目,ABC路径仍报告为未暂停。这是代码:

LOGGER.info(r.getId() + " route supports suspension=" + r.supportsSuspension()); 
context.suspendRoute(r.getId()); 
LOGGER.info("After suspending route " + r.getId() + " the route suspended state is " + ((ServiceSupport) r).isSuspended()); 

及以下日志条目:

[INFO ] my.org.message.router.lifecycle.DeactivateCommand - ABC route supports suspension=true 
[INFO ] org.apache.camel.impl.DefaultShutdownStrategy - Starting to graceful shutdown 1 routes (timeout 300 seconds) 
[INFO ] org.apache.camel.impl.DefaultShutdownStrategy - Route: ABC suspend complete, was consuming from: Endpoint[abc://queue:SOME_QUEUE] 
[INFO ] org.apache.camel.impl.DefaultShutdownStrategy - Graceful shutdown of 1 routes completed in 0 seconds 
[INFO ] org.apache.camel.spring.SpringCamelContext - Route: ABC is suspended, was consuming from: Endpoint[abc://queue:SOME_QUEUE] 
[INFO ] my.org.message.router.lifecycle.DeactivateCommand - After suspending route ABC the route suspended state is false 

所以我的问题是:

  1. 这是一个错误或我做了错误的方式
  2. 如果一个bug存在,或者我应该去停止/启动的方式
  3. 如果我的错误什么是正确的实现我追求的

的方式预先感谢您为您的输入

+0

可能是你的错,因为abc是一个自定义组件,请确保在doSuspend/doResume方法中执行你的工作,而不是暂停/恢复。 –

回答

1

是啊,这是在Apache的骆驼的错误不报告正确的状态 - 路线真的暂停。我已经登录了一张票:https://issues.apache.org/jira/browse/CAMEL-8964

您可以使用camelContext.getRouteStatus(routeId) api得到正确的状态。