当前位置:网站首页>Flowable boundary timer
Flowable boundary timer
2022-06-28 22:38:00 【_ lrs】
Catalog
Preface
Use boundary timer , Remind the unapproved tasks in advance , If users borrow books , The day before the return time , Remind users .
One 、 Process design
The flow chart is as follows


Set the start time on the reminder event , Use ${startTime}.

Two 、xml file
xml The documents are as follows :
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef" exporter="Flowable Open Source Modeler" exporterVersion="6.7.2">
<process id="oneTimejob-process" name=" Test timing reminder " isExecutable="true">
<startEvent id="startEvent1" name=" Start " flowable:formFieldValidation="true"></startEvent>
<endEvent id="sid-86F81954-65D0-4E2A-8DFB-766D26AE15E0" name=" end "></endEvent>
<sequenceFlow id="sid-5CF78305-333A-45DA-AC71-5833231A2602" sourceRef="sid-45452B0C-4C8B-4AEC-AAF1-C869D11CEFB6" targetRef="sid-86F81954-65D0-4E2A-8DFB-766D26AE15E0"></sequenceFlow>
<userTask id="sid-45452B0C-4C8B-4AEC-AAF1-C869D11CEFB6" name=" The return " flowable:assignee="admin" flowable:formFieldValidation="true">
<extensionElements>
<modeler:activiti-idm-assignee xmlns:modeler="http://flowable.org/modeler"><![CDATA[true]]></modeler:activiti-idm-assignee>
<modeler:assignee-info-email xmlns:modeler="http://flowable.org/modeler"><![CDATA[test-[email protected]-domain.tld]]></modeler:assignee-info-email>
<modeler:assignee-info-firstname xmlns:modeler="http://flowable.org/modeler"><![CDATA[admin]]></modeler:assignee-info-firstname>
<modeler:assignee-info-lastname xmlns:modeler="http://flowable.org/modeler"><![CDATA[admin]]></modeler:assignee-info-lastname>
<modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
</extensionElements>
</userTask>
<sequenceFlow id="sid-2452D23F-5DB9-4A2B-AA37-167D0EEE9889" sourceRef="startEvent1" targetRef="sid-45452B0C-4C8B-4AEC-AAF1-C869D11CEFB6"></sequenceFlow>
<boundaryEvent id="sid-D6DB3545-D033-40A7-99D9-59FA84328C76" name=" remind " attachedToRef="sid-45452B0C-4C8B-4AEC-AAF1-C869D11CEFB6" cancelActivity="true">
<extensionElements>
<flowable:executionListener event="start" class="cn.ac.iscas.pdm.biz.rest.test.FlowableEventListenerTest"></flowable:executionListener>
</extensionElements>
<timerEventDefinition>
<timeDate>${
startTime}</timeDate>
</timerEventDefinition>
</boundaryEvent>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_oneTimejob-process">
<bpmndi:BPMNPlane bpmnElement="oneTimejob-process" id="BPMNPlane_oneTimejob-process">
<bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
<omgdc:Bounds height="30.0" width="30.0" x="100.0" y="160.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-86F81954-65D0-4E2A-8DFB-766D26AE15E0" id="BPMNShape_sid-86F81954-65D0-4E2A-8DFB-766D26AE15E0">
<omgdc:Bounds height="28.0" width="28.0" x="450.0" y="161.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-45452B0C-4C8B-4AEC-AAF1-C869D11CEFB6" id="BPMNShape_sid-45452B0C-4C8B-4AEC-AAF1-C869D11CEFB6">
<omgdc:Bounds height="80.0" width="100.0" x="255.0" y="135.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-D6DB3545-D033-40A7-99D9-59FA84328C76" id="BPMNShape_sid-D6DB3545-D033-40A7-99D9-59FA84328C76">
<omgdc:Bounds height="31.0" width="31.0" x="339.97943327875964" y="196.69537188961235"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sid-2452D23F-5DB9-4A2B-AA37-167D0EEE9889" id="BPMNEdge_sid-2452D23F-5DB9-4A2B-AA37-167D0EEE9889" flowable:sourceDockerX="15.0" flowable:sourceDockerY="15.0" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
<omgdi:waypoint x="129.94999949366624" y="175.0"></omgdi:waypoint>
<omgdi:waypoint x="254.99999999993574" y="175.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-5CF78305-333A-45DA-AC71-5833231A2602" id="BPMNEdge_sid-5CF78305-333A-45DA-AC71-5833231A2602" flowable:sourceDockerX="50.0" flowable:sourceDockerY="40.0" flowable:targetDockerX="14.0" flowable:targetDockerY="14.0">
<omgdi:waypoint x="354.95000000000005" y="175.0"></omgdi:waypoint>
<omgdi:waypoint x="450.0" y="175.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
3、 ... and 、 Event listener
Custom listener , Realization FlowableEventListener Interface
@Component
@Slf4j
public class FlowableEventListenerTest implements FlowableEventListener {
@Override
public void onEvent(FlowableEvent event) {
try {
//FlowableEntityEventImpl event
if (event instanceof FlowableEntityEventImpl) {
FlowableEntityEventImpl engineEvent = (FlowableEntityEventImpl) event;
JobEntityImpl job = (JobEntityImpl) engineEvent.getEntity();
// Get task details
String name = job.getElementName();
String processInstanceId = job.getProcessInstanceId();
System.out.println(name);
System.out.println(processInstanceId);
} else {
// Other events
}
} catch (Exception e) {
log.error(" Error executing event listener ,error{}", e);
}
}
@Override
public boolean isFailOnException() {
return false;
}
@Override
public boolean isFireOnTransactionLifecycleEvent() {
return false;
}
@Override
public String getOnTransaction() {
return null;
}
}
Four 、 Register listener
@Configuration
public class GlobalEventListenerConfig {
@Autowired
private RuntimeService runtimeService;
@PostConstruct
public void addListener() {
// The second parameter indicates that only the event of successful task execution is processed , The absence of a second parameter indicates processing FlowableEngineEventType All events for
runtimeService.addEventListener(new FlowableEventListenerTest(), FlowableEngineEventType.JOB_EXECUTION_SUCCESS);
}
}
5、 ... and 、 test
·1、 Loading process
@Test
public void createDeploymentTest() {
Deployment deployment = repositoryService.createDeployment()
.addClasspathResource(" Test timing reminder .bpmn20.xml")
.deploy();
System.out.println(deployment.getId());
}
2、 Start process
@Test
public void startOneTimejobProcessDefinition() {
Map<String, Object> variables = new HashMap<String, Object>();
// Scheduled task start time
variables.put("startTime", "2022-06-26T22:40:00");
// Through process key Boot instance
ProcessInstance processInstance =
runtimeService.startProcessInstanceByKey("oneTimejob-process", variables);
System.out.println(processInstance.getName());
}
When the scheduled task start time comes , If the task has not been approved , Will trigger the logic of the listener .
边栏推荐
- Online linear programming: Dual convergence, new algorithms, and regret bounds
- torch.nn.Transformer导入失败
- Oracle删除归档日志及添加定时任务
- Deploy grafana to realize graphical monitoring
- Explanation: Luogu p1762 even number /6.21 internal examination T2
- Career consultation | in the data analysis interview, it is only reliable to introduce yourself in this way
- 职场进阶 | 了解岗位优势三板斧之“进场”
- 职业问诊 | 面试中被问到意向薪资时,该怎么回答?
- VR全景创业为了把控风险,如何选择加盟公司?
- Water brother's code
猜你喜欢

分享im即时通讯开发之WebSocket:概念、原理、易错常识

Zadig + cave Iast: let safety dissolve in continuous delivery

Deploy grafana to realize graphical monitoring

Zadig 正式推出 VS Code 插件,本地开发更高效

IC Nansha|AMD高级副总裁、大中华区总裁潘晓明:制程、架构、平台优化突破计算边界

超级工厂里的生意图鉴

带链接跳转的微信红包封面制作教程和使用指南

This simple little function saves 213 hours for our production research team in half a year

初识阿里云(云计算)—发展历程和技术架构、地域和可用区!

After crossing, she said that the multiverse really exists
随机推荐
微搭低代码中实现二维码生成
Zadig 构建究竟何强大?一起来实践
C#/VB. Net to convert PDF to excel
On the necessity and solution of building a campus online teaching video convergence platform
This simple little function saves 213 hours for our production research team in half a year
Yiming Anke submitted a statement to the Hong Kong Stock Exchange: the loss doubled in 2021, and the past financing amount was exaggerated
Competition rules for the "network security" event of the secondary vocational group in the skills competition of Guangxi Vocational Colleges in 2022
How to use London gold to draw support resistance line
00 后云原生工程师:用 Zadig 为思创科技(广州公交)研发开源节流
VR全景创业为了把控风险,如何选择加盟公司?
Business atlas in super factory
Redis+aop+ user defined annotation to realize flow restriction
【网关开发】ngx嵌套lua时处理CIDR表示的IP地址段
什么是低代码开发?
DBNN实验进展
Linux安装mysql5.7(CentOS7.6) 教程
Advanced workplace | understand the "entry" of position advantages
What does project management really manage?
ansible生产环境使用场景(七):批量部署elk客户端
Mono 的执行流程