Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Activiti Timer dynamer

We are using activiti for workflow. In one of the flow between one step to another we have wait timer as shown below

<sequenceFlow id="sequence_my_flow_successful_signal_3" sourceRef="my_flow_gateway" targetRef="signal_my_flow_successful_3"/>
    <intermediateCatchEvent id="timer_my_flow_3">
      <timerEventDefinition>
        <timeDuration>PT48H</timeDuration>
      </timerEventDefinition>
    </intermediateCatchEvent>

Is it possible to have an expression which dynamically returns timeDuration (Internally call java code with business key) and have the timerDuration return value based on some condition

I know I could add expression something like below for serviceTask where I could call java code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<serviceTask id="service_my_flow_lead" activiti:exclusive="true" name="Handle My Flow Lean" activiti:expression="${myFlowDelegate.createMyFlowLead(execution.parent.businessKey)}"/>

Thank you

>Solution :

Yes, it is possible to use an expression in a timerEventDefinition to dynamically set the timeDuration. You can use the same approach as in the serviceTask example you provided, i.e. add an expression in the timerEventDefinition and call a Java code with the business key. The expression should return a string that can be parsed into a duration format (e.g. PT48H). An example expression could be:

<timerEventDefinition>
  <timeDuration activiti:expression="${myFlowDelegate.getTimeDuration(execution.parent.businessKey)}"/>
</timerEventDefinition>

In this instance, the expression calls a Java method ‘getTimeDuration‘ in a delegate class ‘myFlowDelegate‘ and passes the business key as an argument. The method should return a string that can be parsed into a duration format.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading