当前位置: 首页 > 知识库问答 >
问题:

无法移除骆驼石英路线

穆仲卿
2023-03-14

我设置了一个endpoint,如下所示:

from("quartz://GroupName/TimerName?stateful=true&cron=0 0/1 * * * ?")
.to("someProcessorBean");
for (Endpoint endpoint : camelContext.getEndpoints()) {
  camelContext.removeEndpoint(endpoint);
}
camelContext.stop();
camelContext.removeRoute(routeId);

我用骆驼石英2.22.2和石英1.8.6

下面是从关闭到启动上下文的日志。

12:22:13,008 DEBUG [DefaultManagementAgent] Unregistered MBean with ObjectName: org.apache.camel:context=CamelContext-MyContext_6.1.1-SNAPSHOT,type=endpoints,name="quartz://MY_GROUP/MY_NAME\?cron=0+0%2F1+\*+\*+\*+%3F&stateful=true"
12:22:13,008 INFO  [SpringCamelContext] Apache Camel 2.22.2 (CamelContext: CamelContext-MyContext_6.1.1-SNAPSHOT) is shutting down
12:22:13,008 INFO  [DefaultShutdownStrategy] Starting to graceful shutdown 1 routes (timeout 300 seconds)
12:22:13,033 INFO  [DefaultShutdownStrategy] Starting to graceful shutdown 1 routes (timeout 300 seconds)
12:22:13,033 DEBUG [DefaultExecutorServiceManager] Created new ThreadPool for source: org.apache.camel.impl.DefaultShutdownStrategy@3a44287c with name: ShutdownTask. -> org.apache.camel.util.concurrent.RejectableThreadPoolExecutor@3fc7873f[Running, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0][ShutdownTask]
12:22:13,034 DEBUG [DefaultShutdownStrategy] There are 1 routes to shutdown
12:22:13,034 INFO  [DefaultShutdownStrategy] Graceful shutdown of 1 routes completed in 0 seconds
12:22:13,034 INFO  [SpringCamelContext] Route: MY_CATEGORY.MY_NAME is stopped, was consuming from: quartz://MY_GROUP/MY_NAME?cron=0+0%2F1+*+*+*+%3F&stateful=true
12:22:13,034 DEBUG [RouteService] Shutting down services on route: MY_CATEGORY.MY_NAME
12:22:13,034 DEBUG [RouteService] Shutting down child service on route: MY_CATEGORY.MY_NAME -> FatalFallbackErrorHandler[Channel[DelegateSync[com.crlcorp.oasis.routing.utils.LauncherErrorHandler@7ccfd046]]]
12:22:13,034 DEBUG [RouteService] Shutting down child service on route: MY_CATEGORY.MY_NAME -> DelegateSync[com.crlcorp.oasis.routing.utils.LauncherErrorHandler@7ccfd046]
12:22:13,034 DEBUG [RouteService] Shutting down child service on route: MY_CATEGORY.MY_NAME -> Channel[DelegateSync[com.crlcorp.oasis.routing.utils.LauncherErrorHandler@7ccfd046]]
12:22:13,034 INFO  [SpringCamelContext] Route: MY_CATEGORY.MY_NAME is shutdown and removed, was consuming from: quartz://MY_GROUP/MY_NAME?cron=0+0%2F1+*+*+*+%3F&stateful=true
12:22:13,078 INFO  [QuartzScheduler] Scheduler meta-data: Quartz Scheduler (v1.8.6) 'DefaultQuartzScheduler-CamelContext-MyContext_6.1.1-SNAPSHOT' with instanceId 'NON_CLUSTERED'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.

12:22:13,078 INFO  [StdSchedulerFactory] Quartz scheduler 'DefaultQuartzScheduler-CamelContext-MyContext_6.1.1-SNAPSHOT' initialized from an externally provided properties instance.
12:22:13,078 INFO  [StdSchedulerFactory] Quartz scheduler version: 1.8.6
12:22:13,078 DEBUG [QuartzComponent] Using SchedulerFactory org.quartz.impl.StdSchedulerFactory@5efaa50e to get/create Scheduler org.quartz.impl.StdScheduler@6d39162c(0x6d39162c)
12:22:13,078 INFO  [QuartzComponent] Starting Quartz scheduler: DefaultQuartzScheduler-CamelContext-MyContext_6.1.1-SNAPSHOT
12:22:13,078 INFO  [QuartzScheduler] Scheduler DefaultQuartzScheduler-CamelContext-MyContext_6.1.1-SNAPSHOT_$_NON_CLUSTERED started.
12:22:13,078 DEBUG [DefaultManagementLifecycleStrategy] Load performance statistics disabled
12:22:13,078 INFO  [SpringCamelContext] Total 0 routes, of which 0 are started
12:22:13,078 INFO  [SpringCamelContext] Apache Camel 2.22.2 (CamelContext: CamelContext-MyContext_6.1.1-SNAPSHOT) started in 0.036 seconds
12:22:13,507 DEBUG [SimpleThreadPool] WorkerThread is shut down.
12:23:00,002 DEBUG [SimpleJobFactory] Producing instance of Job 'DEFAULT.quartz-endpoint1', class=org.apache.camel.component.quartz.StatefulCamelJob
12:23:00,002 DEBUG [JobRunShell] Calling execute on job DEFAULT.quartz-endpoint1
12:23:00,002 DEBUG [CamelJob] Looking up existing QuartzEndpoint with trigger MY_NAME.MY_GROUP
12:23:00,002 DEBUG [QuartzEndpoint] Firing Quartz Job with context: JobExecutionContext: trigger: 'MY_GROUP.MY_NAME job: DEFAULT.quartz-endpoint1 fireTime: 'Mon Jan 07 12:23:00 CST 2019 scheduledFireTime: Mon Jan 07 12:23:00 CST 2019 previousFireTime: 'Mon Jan 07 12:22:00 CST 2019 nextFireTime: Mon Jan 07 12:24:00 CST 2019 isRecovering: false refireCount: 0

共有1个答案

冀嘉木
2023-03-14

升级到camel-quartz2而不是Camel-Quartz。

这个问题与Quartz组件创建两个调度器和在停止路由时只关闭一个有关。这可能是由于路由是有状态的。为了解决这个问题,您可以手动访问与组件相关的所有计划程序并停止所有作业。

log.info("Removing existing endpoints");
for (Endpoint endpoint : camelContext.getEndpoints()) {
  log.info("Removing: " + endpoint.getEndpointUri());
    
  if (endpoint instanceof QuartzEndpoint) {
    QuartzEndpoint quartzEndpoint = (QuartzEndpoint) endpoint;
    
    SchedulerFactory factory = quartzEndpoint.getComponent().getFactory();
    log.debug("Found factory " + factory);
    
    @SuppressWarnings("unchecked")
    Collection<Scheduler> allSchedulers = factory.getAllSchedulers();
    for (Scheduler scheduler : allSchedulers) {
      log.debug("Found Quartz Scheduler" + scheduler.getSchedulerName());
      for (String groupName : scheduler.getJobGroupNames()) {
        for (String jobName : scheduler.getJobNames(groupName)) {
          log.debug(String.format("Unscheduling job %s.%s", groupName, jobName));
          scheduler.deleteJob(jobName, groupName);
        }
      }
    }
  }
  camelContext.removeEndpoint(endpoint);
}
    
log.info("Stopping Camel Context");
camelContext.stop();
    
log.info("Removing existing routes");
RoutesDefinition routes = getRouteCollection();
routes.getOnExceptions().clear();
for (RouteDefinition route : routes.getRoutes()) {
  String routeId = route.getId();
  try {
    log.info("Removing: " + routeId);
    camelContext.removeRoute(routeId);
  } catch (Exception e) {
    log.warn("Could not stop route" + routeId + ": " + e.getMessage());
  }
}
routes.getRoutes().clear();
 类似资料:
  • 问题内容: 我尝试对Apache骆驼路线进行junit测试。像这样的东西: 构建器类的定义如下 “ myExportRouteProcessor”类仅从JPA存储库中获取一些数据,并将结果放入路由。我想要的是在测试类中触发此路由,以检查整个过程是否正确完成。当前,处理器未启动。我该怎么办? 问题答案: 您可以使用AdviceWithRouteBuilder#replaceFromWith直接替换测

  • 我试着为阿帕奇骆驼路线做一个jUnit测试。类似于这样: builder类的定义如下 myExportRouteProcencer类只是从JPA存储库中获取一些数据,并将结果放入路由。我想要的是在测试类中触发此路由,以检查整个过程是否正确完成。目前,处理器没有被触发。我应该做些什么?

  • 我想用Apache Camel和Quartz2按spceific顺序设计路线。我定义了一个上下文,添加了两条路由: 代码构建和运行,但我没有来自控制台的反馈,我期待订单1的路由结果。此外,顺序为2的路由不会写入作为参数传递的文件。每条路线,采取单独正确运行。有人能帮帮我吗?

  • 我有一个Spring boot应用程序,其中包含几条camel路由,这些路由应该基于Quartz2的CronTrigger启动。由于某种原因,只有第一个计划的路由才会启动,但它是在最后一个计划的时间启动的。 路由一:mytime-1h 路由二:mytime 已配置导出路由:WeekProcessingRoute-Schedule:Quartz2:/cronTrigger?cron=041***?

  • 我试着在互联网上找遍了,但没有找到任何关于骆驼石英在运行时更改其时间的适当文档。有没有人知道如何在骆驼路线上开始和停止。

  • 问题内容: 我一直在仔细研究Apache Camel文档,试图对它的两个 最基本 概念(端点和路由)有一个具体的了解,尽管这些术语在文档中各处都使用,但是我找不到真正定义它们的参考。是以及它们的用途。尽管它们的名称听起来很明显,而且我 想 我理解它们的含义,但是现在我已被分配到一项使我深深陷入Apache Camel Land的任务,而了解这些机制的绝对至关重要是。 我的猜测是,“端点”只是一个b