Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-7215

Stop and un-schedule jobs on removal of route

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.12.2
    • 2.12.3, 2.13.0
    • camel-quartz, camel-quartz2
    • None
    • Using job-store 'org.quartz.simpl.RAMJobStore'

    • Unknown

    Description

      When using SimpleScheduledRoutePolicy, jobs are not deleted when a route is removed.

      I got the following exception when removing a route and re-adding it to a running context.

      Stacktrace
      ---------------------------------------------------------------------------------------------------------------------------------------
      org.apache.camel.FailedToCreateRouteException: Failed to create route foo: Route(foo)[[From[quartz... because of org.quartz.ObjectAlreadyExistsException: Unable to store Job : 'jobGroup-foo.job-STOP-foo', because one already exists with this identification.
              at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:182) ~[camel-core-2.12.2.jar:2.12.2]
              at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:770) ~[camel-core-2.12.2.jar:2.12.2]
              at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1914) ~[camel-core-2.12.2.jar:2.12.2]
              at org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:707) ~[camel-core-2.12.2.jar:2.12.2]
              at org.apache.camel.builder.RouteBuilder.populateRoutes(RouteBuilder.java:337) ~[camel-core-2.12.2.jar:2.12.2]
              at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:264) ~[camel-core-2.12.2.jar:2.12.2]
              at org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:669) ~[camel-core-2.12.2.jar:2.12.2]
      
      ...
      
      Caused by: org.apache.camel.RuntimeCamelException: org.quartz.ObjectAlreadyExistsException: Unable to store Job : 'jobGroup-foo.job-STOP-foo', because one already exists with this identification.
              at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1352) ~[camel-core-2.12.2.jar:2.12.2]
              at org.apache.camel.routepolicy.quartz2.SimpleScheduledRoutePolicy.onInit(SimpleScheduledRoutePolicy.java:48) ~[camel-quartz2-2.12.2.jar:2.12.2]
              at org.apache.camel.impl.DefaultRouteContext.commit(DefaultRouteContext.java:202) ~[camel-core-2.12.2.jar:2.12.2]
              at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:916) ~[camel-core-2.12.2.jar:2.12.2]
      
      ...
      
      Caused by: org.quartz.ObjectAlreadyExistsException: Unable to store Job : 'jobGroup-foo.job-STOP-foo', because one already exists with this identification.
              at org.quartz.simpl.RAMJobStore.storeJob(RAMJobStore.java:279) ~[quartz-2.2.1.jar:na]
              at org.quartz.simpl.RAMJobStore.storeJobAndTrigger(RAMJobStore.java:251) ~[quartz-2.2.1.jar:na]
              at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:886) ~[quartz-2.2.1.jar:na]
              at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:249) ~[quartz-2.2.1.jar:na]
              at org.apache.camel.routepolicy.quartz2.ScheduledRoutePolicy.scheduleRoute(ScheduledRoutePolicy.java:116) ~[camel-quartz2-2.12.2.jar:2.12.2]
      

      The SimpleScheduledRoutePolicy should remove the scheduled jobs on route removal. This is what CronScheduledRoutePolicy does.

      Attachments

        Activity

          People

            njiang Willem Jiang
            davidkeen David Keen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: