4 Replies Latest reply on May 14, 2015 2:15 AM by swiderski.maciej

    Loop on JBPM6 Timers

    durani163

      Hi Guys,

       

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

       

      TimersWithUserTask.JPG

       

      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,

      Feroze

        • 1. Re: Loop on JBPM6 Timers
          swiderski.maciej

          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:

           

          R5/PT30S

           

          HTH

          • 2. Re: Loop on JBPM6 Timers
            durani163

            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.

             

            SampleTimerISO.JPG

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

            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.scheduler.skipUpdateCheck=true

             

            org.quartz.scheduler.idleWaitTime=1000

            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.class=org.quartz.impl.jdbcjobstore.JobStoreCMT

            org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate

            org.quartz.jobStore.useProperties=false

            org.quartz.jobStore.dataSource=myDS

            org.quartz.jobStore.nonManagedTXDataSource=notManagedDS

            org.quartz.jobStore.tablePrefix=QRTZ_

            org.quartz.jobStore.isClustered=true

            org.quartz.jobStore.clusterCheckinInterval = 20000

             

            org.quartz.dataSource.myDS.jndiURL=java:comp/env/jdbc/jbpm

            org.quartz.dataSource.notManagedDS.jndiURL=java:comp/env/jdbc/jbpm



            Thanks in Advance,

            Feroze

            • 3. Re: Loop on JBPM6 Timers
              durani163

              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"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xmlns:util="http://www.springframework.org/schema/util"
                     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>

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

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

                <bean id="process" factory-method="newClassPathResource" class="org.kie.internal.io.ResourceFactory">
                  <constructor-arg>
                    <value>sample/sampleTimerUserTask1.bpmn</value>
                  </constructor-arg>
                </bean>
               
                <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">
                    <list>
                      <bean class="org.jbpm.services.task.audit.JPATaskLifeCycleEventListener" />
                    </list>
                  </property>
                </bean>

                <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">
                    <map>
                      <entry key-ref="process"><util:constant static-field="org.kie.api.io.ResourceType.BPMN2"/></entry>
                    </map>
                  </property>
                  <property name="taskService" ref="taskService"/>
                </bean>

                <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>

                <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"/>
               
              </beans>

               

              Thanks In Advance,

              Feroze

              • 4. Re: Loop on JBPM6 Timers
                swiderski.maciej

                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.

                 

                HTH