Apache camel 对驼峰路由应用超时控制

Apache camel 对驼峰路由应用超时控制,apache-camel,Apache Camel,我想启动一个路由并应用定时器/超时控制设置。如果路由未在超时之前完成,则可能引发异常,并且必须停止原始路由线程(路径)。我看过NotifyBuilder、SEDA、Timer+wiretap、聚合器和Camel BAM。它们中似乎没有一个具有停止原始路由线程的内置功能。你有什么建议吗?谢谢 这是我正在考虑的代码框架: OnException(Exception.class) .handled(true) .to(dead_uri).end()// handle timeout excep

我想启动一个路由并应用定时器/超时控制设置。如果路由未在超时之前完成,则可能引发异常,并且必须停止原始路由线程(路径)。我看过NotifyBuilder、SEDA、Timer+wiretap、聚合器和Camel BAM。它们中似乎没有一个具有停止原始路由线程的内置功能。你有什么建议吗?谢谢

这是我正在考虑的代码框架:

OnException(Exception.class)  
.handled(true)  
.to(dead_uri).end()// handle timeout exception and quite the current route thread  

from(uri)  
  //start timer or set timeout something  
  .to(process_uri);  

我知道Camel JMS有超时控制,但我不想仅仅因为路由需要超时而使用JMS。SEDA具有超时控制,但SEDA超时将位于不同的线程中。如何停止“process_uri”的原始线程

如果您想在路由未在指定时间内完成的情况下停止路由,我想再使用一个计时器检查路由是否已完成处理。(查看路由策略)-如果这对您有帮助的话

并使用controbus停止/启动路线

from("timer://checkIfProcessed?repeatCount=1")
    .process(new Processor(){
void process(Exchange exc){
// check the status of the route and send a signal using controlbus , u could use if(status?)
producerTempalte.asyncSend("controlbus:route?routeId="+"theRouteYouWantToStop"+"&action=stop", exchange);
}
}
).end();
这里有一个catch,它的处理不会停止,因此您必须从InflightRepository中删除交换


希望这能有所帮助。

通常,当从路由调用到您无法控制的同步协议时,您通常会在其中设置超时值。您可能希望提供更多关于路由的详细信息,以便人们为您找到解决方案。另一件事:SEDA和JMS组件具有超时值,也就是说,您可以放置一个请求,该请求只等待一段时间的回复,如果发生超时,您应该能够抛出一个执行选项(从而终止部分交换)(或者至少,把它放到错误处理程序中)。谢谢@Petter。我添加了原始内容,并将在SEDA上尝试更多内容。由于SEDA处于异步方案中,超时仅通知生产者,“特定交换”即消费者如何在超时时终止?