cancel
Showing results for 
Search instead for 
Did you mean: 

Execute an action in Timer Boundary Event

lpavone
Champ in-the-making
Champ in-the-making
Hi all,
I'm trying to execute a Java Action in a Timer Boundary Event but without take a flow, just keeping in the same task.
Is it possible? or is there another alternative?

I'm looking send a remainder (by mail) when the timer expire but no cancelling the task and no taking any flow.

Thanks.
8 REPLIES 8

webcyberrob
Champ in-the-making
Champ in-the-making
Hi there,

couldn't your timer expiry event take a new path which goes through a decision gate. If first time, continue on to send email task then loop back to the original task and set the process loop counter +1. If not first time, take a flow which effectively abandons the task…

frederikherema1
Star Contributor
Star Contributor
You can mark your boundary-event as non-interupting (cancelActivity="false"). This way, the activity the boundary-event is attached to, won't be ended when the timer fires but rather, a separate parallel flow will be created for this event:


<boundaryEvent id="escalationTimer" cancelActivity="false" attachedToRef="firstLineSupport">
     <timerEventDefinition>
      <timeDuration>${duration}</timeDuration>
    </timerEventDefinition>
  </boundaryEvent>

lpavone
Champ in-the-making
Champ in-the-making
Thanks everybody!

Frederick solutions is like I thought in first moment, but I was looking another way without a new parallel flow…
Anyway I will use that solution to customize the email alert for any expired task.
This forum is really amazing, very fast, useful and supported by Activiti developers.
Thanks a lot!

shimu
Champ in-the-making
Champ in-the-making
Hi,

I have a similar use case, where reminder emails need to be sent if the user task is not completed in 3 days. The user task on which the timer is attached is a multi instance parallel task. The user task itself should not be cancelled on the time trigger. I have attached the boundary timer to my concurrent approval task and have a sequence flow to an end event. I tried setting the cancelActivity to "false" and it threw exception every 3mins(have this set for testing purpose) , interestingly if I set the cancelAcitivity to "true", it works and the workflow ends. Is there any other setting I might be missing to attach the timer to a multi instance user task?

Below have copy/pasted my workflow config:

</sequenceFlow>
      <boundaryEvent id="boundarytimer1" name="Timer" attachedToRef="concurrentApproval" cancelActivity="false">
      <timerEventDefinition>
      <timeDuration>PT3M</timeDuration>
      </timerEventDefinition>
    </boundaryEvent>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow27" sourceRef="boundarytimer1" targetRef="endevent2">
      <extensionElements>
        <activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
          <activiti:field name="script">
            <activiti:string>
                   logger.log("SEND TIMER EMAIL");
            </activiti:string>
          </activiti:field>
        </activiti:executionListener>
      </extensionElements>
    </sequenceFlow>
<userTask id="concurrentApproval" name="Concurrent Approval Task" activiti:assignee="${approverAssignee}" activiti:formKey="wf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
           <activiti:field name="runAs">
            <activiti:string>admin</activiti:string>
          </activiti:field>
          <activiti:field name="script">
            <activiti:string>if (task.getVariableLocal('wf_reviewOutcome') == 'Reject') {
               var newApprovalRejectCount = wf_approvalRejectCount + 1;
              execution.setVariable('wf_approvalRejectCount', newApprovalRejectCount);
             }
            execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));</activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.CiscoScriptTaskListener">
           <activiti:field name="runAs">
            <activiti:string>admin</activiti:string>
          </activiti:field>
           <activiti:field name="script">
            <activiti:string> if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                      if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;</activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="wf_groupApprovers" activiti:elementVariable="approverAssignee">
      <completionCondition>wf_approvalRejectCount&gt;1</completionCondition>
      </multiInstanceLoopCharacteristics>
    </userTask>


12:42:16,388 ERROR [org.springframework.transaction.support.TransactionSynchronizationUtils] TransactionSynchronization.afterCompletion threw exception
java.lang.IllegalStateException: No value for key [org.apache.ibatis.session.defaults.DefaultSqlSessionFactory@b3ef378] bound to thread [pool-5-thread-5]
at org.springframework.transaction.support.TransactionSynchronizationManager.unbindResource(TransactionSynchronizationManager.java:199)
at org.mybatis.spring.SqlSessionUtils$SqlSessionSynchronization.suspend(SqlSessionUtils.java:243)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.doSuspendSynchronization(AbstractPlatformTransactionManager.java:666)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.suspend(AbstractPlatformTransactionManager.java:569)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:418)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:347)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:127)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.activiti.engine.impl.jobexecutor.DecrementJobRetriesListener.execute(DecrementJobRetriesListener.java:38)
at org.activiti.spring.SpringTransactionContext$4.afterCompletion(SpringTransactionContext.java:82)
at org.springframework.transaction.support.TransactionSynchronizationUtils.invokeAfterCompletion(TransactionSynchronizationUtils.java:168)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.invokeAfterCompletion(AbstractPlatformTransactionManager.java:996)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerAfterCompletion(AbstractPlatformTransactionManager.java:971)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:874)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:822)
at org.springframework.transaction.support.TransactionTemplate.rollbackOnException(TransactionTemplate.java:161)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:134)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:36)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
12:45:16,603 ERROR [org.springframework.transaction.support.TransactionSynchronizationUtils] TransactionSynchronization.afterCompletion threw exception

frederikherema1
Star Contributor
Star Contributor
Can you see an earlier exception, other than the "no key" exception? Seems to be an issue with timer an transactions. What version of Alfresco are you running?

shimu
Champ in-the-making
Champ in-the-making
That is the first exception. I also noticed that if I attached the timer to a multi instance sequential user task it works. I am on Alfresco 4.1.3 enterprise.

frederikherema1
Star Contributor
Star Contributor
-> I also noticed that if I attached the timer to a multi instance sequential user task it works.

So attaching the boundary-event to a single task, using cancelActivity="false" throws the exception but when attaching the boundary-event to a single task, using cancelActivity="false" to a multi-instance task is successful?

Any other stack traces/errors in the console before or after the ibatis-exception? Seems like the transaction has been rolled back/ gone already when activiti flushes it's changes.

deepyamanchatte
Champ in-the-making
Champ in-the-making
TimerBoundaryEvent working inconsistently with UserTask in ver 5.17 Community.
Configuration on the TimerBoundaryEvent:cancelActivity=false