6 Replies Latest reply on Mar 15, 2010 5:37 AM by preetigupta

    Repeat timer only once

      Hi,

       

      I am new to JBPM and currently need to develop workflow on JBPM 3.

      I have a requirement where Timer or reminder on the task should be repeated but only once.

       

       

      <task name="review" swimlane="reviewer">
      <timer duedate="10 seconds" repeat="2 seconds">
              <script>      
      System.out.println("Hello");
              </script>
      </timer>
      </task>
              <transition name="approve" to="approved"/>
              <transition name="reject" to="rejected" />

              </task>

       

      Please direct me how to achieve this.

       

      Thanks and Regards

      Preeti Gupta

        • 1. Re: Repeat timer only once
          swiderski.maciej

          Hi,

           

          if you use duedate only that should do what you expect. In your case if timer will have only duedate="10 seconds" then execution will happen in 10 seconds and timer will be canceled/closed.

           

          Cheers,

          Maciej

          • 2. Re: Repeat timer only once

            Hi Maciej

             

            Thanks for the reply. I understand this. But I have to repeat timer once after due date. In total timer has to run two times. One at due date, then after the repeat interval and then it should be expired. Hope you help me in this scenario.

             

            Thanks and Regards

            Preeti Gupta

            • 3. Re: Repeat timer only once
              swiderski.maciej

              You could try to create two timers instead of one that has repeat attribute.

               

              I tested following configuration on a wait state:

                  <on event="timeout">
                    <timer duedate="10 minutes"/>
                    <event-listener class="EventListenerClass" />
                  </on>
                  <on event="timeout">
                    <timer duedate="20 minutes"/>
                    <event-listener class="EventListenerClass" />
                  </on>
              

              please note that I tested it on 4.3 version so I can't say if that will work properly for version 3.

               

              As soon as transition is taken to move forward all timers will be canceled/closed.

               

              HTH

              Maciej

              1 of 1 people found this helpful
              • 4. Re: Repeat timer only once

                Hi Maciej

                 

                Thanks for the reply and analysis.

                I already need to implement more than one timer, so the way you suggested, I would in total have three timers on that state. I will try and hope that should work.

                 

                Beside this, I need to send reminder mail to user. But its like reminder1 and reminder2 should follow templateA. But after that reminder mail should follow templateB. Is it possible to change template through code? Or to specify two reminder actions on one task.

                 

                Thanks and Regards

                Preeti Gupta

                • 5. Re: Repeat timer only once
                  swiderski.maciej

                  Unfortunately you cannot add more than one reminder. I mean you can add it but only first one will be created.

                   

                  What I could suggest you here to do is to try to use parameters with the template and modify these parameters. So lets consider following template:

                      <mail-template name="my-dynamic-template">
                        <to addresses="${addressee}" />
                        <subject>${subject}</subject>
                        <text>${title} ${header} ${body} ${footer}</text>
                      </mail-template>
                  

                  And then when executing reminder will rely on process variables to fill in the template. Perhaps you could setup event listener that will be notified as soon as reminder goes off and if you reach number of reminders sent with default values then you could update them and new values will be set when sending next time.

                   

                  Did not try it my self but I think it is worth spending some time to check if that will work.

                   

                  Cheers

                  Maciej

                  1 of 1 people found this helpful
                  • 6. Re: Repeat timer only once

                    Thanks. I will try this way.

                     

                    Regards

                    Preeti Gupta