4 Replies Latest reply on May 14, 2015 2:15 AM by Maciej Swiderski

    Loop on JBPM6 Timers

    Feroze Durani SK Newbie

      Hi Guys,


      I have been working on Timers of Jbpm6.1.0 with Oracle + Tomcat. I am trying on the below scenario, For example,




      In the above process, I have mentioned timer duration:30s & timer cycle:30s for PMTimer node. I wanted to execute the timer node only for 5 times. In short, I wanted

      to put loop count on timers. For this, I have considered a loop count flag(PMTimerFlag) as a process variable. And, I am trying to increment it using script task.

      And, I have taken diverging gateway to check PMTimer loop counter.


      As per the above process I could successfully update the count flag, but the PMTimer node is not FIRING for every 30s once after it reaches to Script Task1. If I remove script Task which has update of process variable (loop count flag), then timer node is getting invoked for every 30 seconds. But I wanted to stop the timer node after 5 times.

      It would be very very helpful if someone could help me to resolve this.


      Thanks In Advance,


        • 1. Re: Loop on JBPM6 Timers
          Maciej Swiderski Master

          you can use ISO date format to do what you need without any loops or additional process variables. For your use case it should be enough to set this value for timer cycle event definition:





          • 2. Re: Loop on JBPM6 Timers
            Feroze Durani SK Newbie

            Hi Maciej,


            Thanks a lot for your response. I have already tried to implement the above scenario with ISO date format and did not succeed on it. Hence, I have opted for the above implementation.


            Below is the scenario that I have tried for loop on JBPM timers.



















            In this scenario I just have a user task which has to timeout after 30S and need to execute script task for five times at 30s interval. I have configured exactly what you have mentioned. But couldn't be able to proceed further on the same.


            I am guessing there might be some problem in quartz properties. Please find the quartz configuration.



            org.quartz.scheduler.instanceName = TestScheduler

            org.quartz.scheduler.instanceId = instance_one




            org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool

            org.quartz.threadPool.threadCount = 1

            org.quartz.threadPool.threadPriority = 5


            org.quartz.jobStore.misfireThreshold = 60000









            org.quartz.jobStore.clusterCheckinInterval = 20000




            Thanks in Advance,


            • 3. Re: Loop on JBPM6 Timers
              Feroze Durani SK Newbie

              In addition to the above quartz configuration, below is the jbpm configuration with spring.


              1. jbpm-config.xml


              <?xml version="1.0" encoding="UTF-8"?>
              <beans xmlns="http://www.springframework.org/schema/beans"
                     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                                        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">


              <bean id="jbpmEMF" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
                <property name="persistenceUnitName" value="org.jbpm.persistence.spring.local" />
                  <property name="persistenceXmlLocation" value="classpath:spring/persistence-local.xml"/>

              <bean id="jbpmEM" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
                <property name="entityManagerFactory" ref="jbpmEMF" />

              <bean id="jbpmTxManager" class="org.springframework.orm.jpa.JpaTransactionManager">
                <property name="entityManagerFactory" ref="jbpmEMF" />

                <bean id="process" factory-method="newClassPathResource" class="org.kie.internal.io.ResourceFactory">
                <bean id="taskService" class="org.kie.spring.factorybeans.TaskServiceFactoryBean" destroy-method="close">
                  <property name="entityManagerFactory" ref="jbpmEMF"/>
                  <property name="transactionManager" ref="jbpmTxManager"/>
                  <property name="userGroupCallback" ref="customUserGroupCallback"/>
                  <property name="listeners">
                      <bean class="org.jbpm.services.task.audit.JPATaskLifeCycleEventListener" />

                <bean id="runtimeEnvironment" class="org.kie.spring.factorybeans.RuntimeEnvironmentFactoryBean">
                  <property name="type" value="DEFAULT"/>
                  <property name="entityManagerFactory" ref="jbpmEMF"/>
                  <property name="entityManager" ref="jbpmEM"/>
                  <property name="transactionManager" ref="jbpmTxManager"/>
                  <property name="schedulerService" ref="timerService"/>
                  <!-- <property name="registerableItemsFactory" ref="workItems"/> -->
                  <property name="assets">
                      <entry key-ref="process"><util:constant static-field="org.kie.api.io.ResourceType.BPMN2"/></entry>
                  <property name="taskService" ref="taskService"/>

                <bean id="runtimeManager" class="org.kie.spring.factorybeans.RuntimeManagerFactoryBean" destroy-method="close">
                  <property name="identifier" value="spring-rmf"/>
                  <property name="runtimeEnvironment" ref="runtimeEnvironment"/>
                  <property name="type" value="PER_PROCESS_INSTANCE"/>

                <bean id="customUserGroupCallback" class="com.trials.jbpm.process.beans.CustomUserGroupCallback"/>
                <bean id="customWorkItemHandler" class="com.trials.jbpm.process.beans.HelloProcessExtension"/>
                <bean id="timerService" class="org.jbpm.process.core.timer.impl.QuartzSchedulerService"/>


              Thanks In Advance,


              • 4. Re: Loop on JBPM6 Timers
                Maciej Swiderski Master

                you should use only one event definition - meaning either timer cycle or timer duration. I'd recommend use timer cycle only with ISO format and it should work as expected as there are number of test cases proving this works.