6 Replies Latest reply on Oct 7, 2009 6:25 AM by newcomer1

    How to start JobExecutor with jBPM 4 + Spring

    Joe Schmoe Newbie

      Does anyone have any idea how to start the JobExecutor? I have configured the JobExecutor in the jbpm.cfg.xml file and it is working. However, it only seems to run when an asynchronous activity is started (ie: a task with a timeout in it is created).

      According to the documentation I just need to add this line to my jbpm.cfg.xml:

      <job-executor threads="4" idle="15000" idle-max="60000" lock-millis="3600000" />

      I'm concerned because the JobExecutor does not seem to run when the server is started such as in a server restart. Therefore if I had old jobs from before the server was shut down, they would not run.

      I'm running jBPM 4 in a Spring container if that matters.

        • 1. Re: How to start JobExecutor with jBPM 4 + Spring
          Mustafa Musaji Novice

          I'm guessing you've done a search for this topic.

          http://www.jorambarrez.be/blog/2008/08/26/jbpm-job-executor-for-spring/

          I'm using JobExecutor but not in Spring framework. Works well other than concurrency issues with the database which I can't get my head around at the moment. I've done exactly what you described, configured it and added the line (albeit with amended timings).

          • 2. Re: How to start JobExecutor with jBPM 4 + Spring
            Joe Schmoe Newbie

            Yes, I have done a search and read that article. But that article is for jBPM3. Not jBPM4.

            The class "org.jbpm.JbpmConfiguration" does not even exist in jBPM4.

            Any other ideas on how to get jBPM4 JobExecutor to start up in a Spring environment?

            I have tried the Servlet method but the JobExecutor is unable to find the transaction manager when started in this way.

            • 3. Re: How to start JobExecutor with jBPM 4 + Spring
              Joe Schmoe Newbie

              No one? Is the JobExecutor supported in a Spring environment using a Jta Transaction Manager? I would be happy to help with troubleshooting if anyone would point me in the right direction.

              • 4. Re: How to start JobExecutor with jBPM 4 + Spring
                kwangcheol min Newbie

                I have faced same issues.
                I'll appreciate if anyone will help us.
                Thanks.

                • 5. Re: How to start JobExecutor with jBPM 4 + Spring
                  sdfsd sdfsd Newbie

                  I have done something like this:

                  import org.jbpm.api.ProcessEngine;
                  import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
                  import org.springframework.beans.factory.annotation.Required;
                  import org.springframework.context.ApplicationEvent;
                  import org.springframework.context.ApplicationListener;
                  import org.springframework.context.event.ContextClosedEvent;
                  import org.springframework.context.event.ContextRefreshedEvent;
                  
                  
                  public class JbpmJobExecutorLoader implements ApplicationListener {
                  
                   private ProcessEngine processEngine;
                  
                   @Required
                   public void setProcessEngine(ProcessEngine processEngine) {
                   this.processEngine = processEngine;
                   }
                  
                   public void onApplicationEvent(ApplicationEvent applicationEvent) {
                   if (applicationEvent instanceof ContextRefreshedEvent) {
                   JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
                   if (!jobExecutor.isActive()) {
                   jobExecutor.start();
                   }
                   } else if (applicationEvent instanceof ContextClosedEvent) {
                   JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
                   jobExecutor.stop();
                   }
                   }
                  


                  processEngine will be wired by Spring.

                  • 6. Re: How to start JobExecutor with jBPM 4 + Spring
                    newcomer1 Newbie

                     

                    "unsavory" wrote:
                    Does anyone have any idea how to start the JobExecutor? I have configured the JobExecutor in the jbpm.cfg.xml file and it is working. However, it only seems to run when an asynchronous activity is started (ie: a task with a timeout in it is created).

                    According to the documentation I just need to add this line to my jbpm.cfg.xml:

                    <job-executor threads="4" idle="15000" idle-max="60000" lock-millis="3600000" />

                    I'm concerned because the JobExecutor does not seem to run when the server is started such as in a server restart. Therefore if I had old jobs from before the server was shut down, they would not run.

                    I'm running jBPM 4 in a Spring container if that matters.


                    We are also running jBPM 4 in spring + JTA and we are not having the same problem as you describe. We start our spring context from a simple war project that uses a parent spring context loader at the ear level (we are also using ejbs). When the application is started the jobexecutor is started automaticly as we have setup spring to execute the buildProcessEngine factory method on SpringJbpmConfiguration at spring startup (lazy-init=false).