Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-3089

ThreadSafeTrackableTimeJobFactoryManager for default

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 7.13.0.Final
    • 7.12.0.Final
    • core engine
    • 2018 Week 39-41
    • NEW
    • NEW

      By default, TrackableTimeJobFactoryManager is set by SessionConfigurationImpl.

      https://github.com/kiegroup/drools/blob/7.11.0.Final/drools-core/src/main/java/org/drools/core/SessionConfigurationImpl.java#L175-L176

      If users access a ksession via multiple threads, it would potentially hit a HashMap concurrency issue (e.g. https://stackoverflow.com/questions/22944918/why-does-the-code-hang-with-hashmap-put-from-multiple-threads).

      ThreadSafeTrackableTimeJobFactoryManager is bundled for multi-thread use. You can use it by

      Drools 7:

      System.setProperty("drools.timerJobFactory", "thread_safe_trackable");
      

      Drools 6.3+:

      KieSessionConfiguration kconf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
      ((org.drools.core.SessionConfiguration)kconf).setTimerJobFactoryType( TimerJobFactoryType.THREAD_SAFE_TRACKABLE );
      KieSession ksession = kContainer.newKieSession("ksession-name", kconf);
      

      However, it's better to make ThreadSafeTrackableTimeJobFactoryManager default because "Suddenly hitting an issue in production" is significant than "small overhead by ConcurrentHashMap". (Generally, users are not very conscious about "it is accessed by multi-threads or not")

              mfusco@redhat.com Mario Fusco
              rhn-support-tkobayas Toshiya Kobayashi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: