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

Quartz2 firenow doesn't work consistently

    XMLWordPrintableJSON

    Details

    • Estimated Complexity:
      Moderate

      Description

      Hi Colleagues,

      We have an interesting bug in the camel-quartz2 where the firenow doesn't work consistently.

      it works sometimes and sometimes it doesn't. On debug i found that the problem occurs when Scheduler starts it invokes CamleJob,  CamleJob starts executing and tries to read from getProcessors() method of LoadBalancerSupport class. sometimes getProcessors() method returns empty list as a result routes doesn't get executed.

      StartupListener (QuartzComponent) gets notified much before the QuartzConsumer starts, as a result it is not able to get the List<Processor> from getProcessors() method of LoadBalancerSupport class.

       

      Analysis of the problem

      --------------------------------------------------------------------------------------------------

      1. DefaultCamelContext method safelyStartRouteServices() notifies QuartzComponent's onCamelContextStarted() method.
      2. The above step starts the scheduler which then calls execute() method in CamelJob class.
      3. In the execute() method it invokes getProcessors() method of LoadBalancerSupport class to get the List<Processor>.
      4. Sometimes getProcessors()  returns empty list.
      5. The reason is  List<Processor> in LoadBalancerSupport class is populated by QuartzConsumer on start of consumer. but  it is started after QuartzComponent's onCamelContextStarted() method is called in DefaultCamelContext.
      6. When i checked the older version of camel which we are using in our organization 2.17.0 i see the order is different.
      7. Consumer starts first then the classes that implements StartupListener.

      To Summarize

      -------------------------------------------------------------------------------------------------------

      1. The order in which StartupListener and Consumer is started in DefaultCamelContext is causing race condition.
      2. The older version of camel 2.17.0 order is first Consumer starts followed by classes that implement StartupListener

       

      I have attached the junit with quartz2, since it is intermittent issue, i made the junit to run 1000 times and it fails randomly which proves existence of the problem.

      I have also attached by proposed solution in DefaultCamelContext in the attachment.

       

       

        Attachments

        1. Solution.java
          3 kB
          Deepak
        2. cameltest.zip
          12 kB
          Deepak

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              deepaktaker Deepak
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: