Apache camel 多次重试后停止骆驼
我正在尝试实现更高级的Apache Camel错误处理: 若有太多的挂起重试,则停止处理,并将收集到的所有异常记录在某个位置 第一部分(在太多重试时停止)已通过以下帮助器方法实现,该方法获取重试队列的大小,如果队列超过某个限制,我将停止上下文:Apache camel 多次重试后停止骆驼,apache-camel,Apache Camel,我正在尝试实现更高级的Apache Camel错误处理: 若有太多的挂起重试,则停止处理,并将收集到的所有异常记录在某个位置 第一部分(在太多重试时停止)已通过以下帮助器方法实现,该方法获取重试队列的大小,如果队列超过某个限制,我将停止上下文: static Long getToRetryTaskCount(CamelContext context) { Long retryTaskCount = null; ScheduledExecutorService erro
static Long getToRetryTaskCount(CamelContext context) {
Long retryTaskCount = null;
ScheduledExecutorService errorHandlerExecutor = context.getErrorHandlerExecutorService();
if (errorHandlerExecutor instanceof SizedScheduledExecutorService)
{
SizedScheduledExecutorService svc = (SizedScheduledExecutorService) errorHandlerExecutor;
ScheduledThreadPoolExecutor executor = svc.getScheduledThreadPoolExecutor();
BlockingQueue<Runnable> queue = executor.getQueue();
retryTaskCount = (long) queue.size();
}
return retryTaskCount;
}
静态长getToRetryTaskCount(CamelContext){
Long retryTaskCount=null;
ScheduledExecutorService errorHandlerExecutor=上下文。getErrorHandlerExecutorService();
if(errorHandlerExecutor instanceof SizedScheduledExecutorService)
{
SizedScheduledExecutorService svc=(SizedScheduledExecutorService)errorHandlerExecutor;
ScheduledThreadPoolExecutor=svc.getScheduledThreadPoolExecutor();
BlockingQueue=executor.getQueue();
retryTaskCount=(长)队列.size();
}
返回retryTaskCount;
}
但是我觉得这段代码很难闻,我不喜欢它,而且我在这里也看不到任何方法来收集所有这些重试导致的异常 我不会试图关闭CamelContext,只关闭有问题的路由……这样,应用程序的其余部分仍然可以运行,您可以获取路由统计信息,查看/移动消息到备用队列,等等
请参见我不会尝试关闭CamelContext,只会关闭有问题的路由…这样,应用程序的其余部分仍然可以正常运行,您可以获取路由统计信息,查看/移动消息到备用队列,等等
请参见骆驼2.11中还有一个新的控制总线组件,它可以实现您想要的功能()
camel 2.11中还有一个新的控制总线组件,它可以实现您想要的功能()
template.sendBody("controlbus:route?routeId=foo&action=stop", null);