So Yesterday I started learning Activiti with Spring Boot. There are many tutorials on the internet in which
Suppose there is only one task in my workflow i.e. to send email to a user.
So, The problem is, I am not able to understand that Where Do I need to write the code to Send Email
Basically, once I started a task, which code it will execute?
I've searched entire internet but no able to find any solution. I am completely a beginner in this.
Any help will be appreciated.
1. Use below content for your bpmn.xml file as per requirement,
<?xml version="1.0" encoding="UTF-8"?>
<definitions
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="Examples">
<process id="oneTaskProcess" name="The Email task">
<startEvent id="theStart" />
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="emailTask" />
<serviceTask id="emailTask"
name="Email task service invocation"
activiti:class="com.mycompany.SendEmail">
</serviceTask>
<sequenceFlow id="flow2" sourceRef="emailTask" targetRef="theEnd" />
<endEvent id="theEnd" />
</process>
</definitions>
2.Create a service task using java as below,
package com.mycompany.SendEmail;
public class SendEmail implements ActivityBehavior {
@Override
public void execute(ActivityExecution execution) throws Exception {
PvmTransition transition = null;
// do your business logic.
try{
transition = execution.getActivity().findOutgoingTransition("theEnd");
}catch (Exception e){
//do nothing
}
execution.take(transition);
}
}