2 Replies Latest reply on May 15, 2014 2:00 AM by Evan James Knowles

    Setting a custom TimerJobFactoryManager

    Evan James Knowles Newbie

      Hey,

       

      I'm trying to set a custom TimerJobFactoryManager, but I'm not certain how this could be done.

       

      I've setup a custom Scheduler, figuring that I could set the TimerJobFactoryManager in the initScheduler method, but in GlobalTimerService the jobFactoryManager is instantiated (via reflection for some reason?) after the initScheduler is called. Also, I see that the setTimerJobFactoryManager method on the GlobalTimerService actually sets only the CommandService on the timer job factory manager, not the manager itself.

       

      Is there some other way that I can setup this up? Thanks.

        • 1. Re: Setting a custom TimerJobFactoryManager
          Maciej Swiderski Master

          to change the TimerJobFactoryManager you'll need to provide your own TimerService impl and all other components that it utilizes. This is because they do heavily rely on its capabilities and then it might be rather complex to change just one component.

           

          Could you elaborate why you need to change TimerJobFactoryManager?

           

          HTH

          • 2. Re: Setting a custom TimerJobFactoryManager
            Evan James Knowles Newbie

            Basically, I'm using jBPM within a framework that already exists in our system. It relies heavily on container managed transactions so we've enabled those within jBPM. jBPM is working perfectly in general - creating processes / tasks, starting them, completing them etc.


            The issue came in when we started using timers - as the timer job is triggered from the thread pool, there is no container managed transaction and we start getting no transaction in progress messages.

             

            Our workaround for now is to extend GlobalJpaTimerJobInstance and manually create the transaction, call super.call() and then commit the transaction. For this it seemed that it would be easiest to use a custom TimerJobFactoryManager and get it to return our custom GlobalJpaTimerJobInstance.

             

            For now I've basically just mirrored the functionality of ThreadPoolSchedulerService so that it uses a handed in TimerJobFactoryManager and then set that up on the RuntimeEnvironmentBuilder.

             

            This is working fine, in that the timed jobs are now triggering and advancing states.

             

            Unfortunately the timers aren't persisting through server bounces - I'm not sure if that's because of my changes or because I've just set them up incorrectly. It appears that all of the Timers are kept serialized in SessionInfo? The SessionInfo entry hasn't been updated however - each time I boot up the server it runs the three timers that were last persisted, and any new timers are lost.

             

            Is there a way that I can manually trigger this update? It seems that having to reserialize all of the timers each time a new timer is created could cause performance issues?

             

            Thanks!