activiti6定时器
xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/testm1552011432748" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1552011432748" name="" targetNamespace="http://www.activiti.org/testm1552011432748" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="testProcess02" isClosed="false" isExecutable="true" name="testProcess02" processType="None">
<userTask activiti:exclusive="true" id="_3" name="UserTask1"/>
<userTask activiti:exclusive="true" id="_6" name="UserTask3"/>
<startEvent id="_2" name="StartEvent"/>
<endEvent id="_7" name="EndEvent"/>
<sequenceFlow id="_8" sourceRef="_6" targetRef="_7"/>
<intermediateCatchEvent id="_5" name="IntermediateCatchingEvent">
<timerEventDefinition id="_5_ED_1">
<timeCycle><![CDATA[0/60 * * * * ?]]></timeCycle>
</timerEventDefinition>
</intermediateCatchEvent>
<sequenceFlow id="_9" sourceRef="_2" targetRef="_5"/>
<sequenceFlow id="_10" sourceRef="_5" targetRef="_3"/>
<sequenceFlow id="_12" sourceRef="_3" targetRef="_6"/>
</process>
<bpmndi:BPMNDiagram documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
<bpmndi:BPMNPlane bpmnElement="testProcess02">
<bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3">
<dc:Bounds height="55.0" width="85.0" x="300.0" y="140.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_6" id="Shape-_6">
<dc:Bounds height="55.0" width="85.0" x="415.0" y="385.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<dc:Bounds height="32.0" width="32.0" x="325.0" y="-10.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_7" id="Shape-_7">
<dc:Bounds height="32.0" width="32.0" x="325.0" y="490.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" id="Shape-_5">
<dc:Bounds height="32.0" width="32.0" x="325.0" y="45.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_12" id="BPMNEdge__12" sourceElement="_3" targetElement="_6">
<di:waypoint x="385.0" y="167.5"/>
<di:waypoint x="415.0" y="412.5"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8" sourceElement="_6" targetElement="_7">
<di:waypoint x="455.0" y="440.0"/>
<di:waypoint x="455.0" y="465.0"/>
<di:waypoint x="357.0" y="506.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_9" id="BPMNEdge__9" sourceElement="_2" targetElement="_5">
<di:waypoint x="341.0" y="22.0"/>
<di:waypoint x="341.0" y="45.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_10" id="BPMNEdge__10" sourceElement="_5" targetElement="_3">
<di:waypoint x="341.0" y="77.0"/>
<di:waypoint x="341.0" y="140.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
正常部署启动即可:0/60 * * * * ?
为cron表达式,意思为每60秒自动发起一次流程实例。
DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService()
.createDeployment()
.addClasspathResource("test.bpmn")
Deployment deployment = deploymentBuilder.deploy();
ProcessDefinition processDefinition = processEngine.getRepositoryService().createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
System.out.println("==============" + processDefinition.getId());
processEngine.getProcessEngineConfiguration().getAsyncExecutor().start();//注意这句话开启定时器,一定要加