flowable-流程中心設計之中間事件(六)


簡介 

中間捕獲事件,是可以作為一個流程節點存在,可以是拋出型,也可以是捕獲型的
拋出型:拋出事件等待其他捕獲型捕獲比如開始事件、中間捕獲事件、邊界事件
捕獲型:則是接收拋出型拋出的事件

中間定時事件

說明

中間定時事件是一個捕獲事件,當執行到達捕獲事件節點, 就會啟動一個定時器。 當定時器觸發(一段時間之后),流程就會沿着定時中間事件的外出節點繼續執行。
可觀察select * from act_ru_timer_job 此表

設計

用戶下單節點完成后,會到達中間定時事件節點,同時select * from act_ru_timer_job 在這個表生成一條job記錄 到達指定事件則完成此節點

相關參數設置

timeDate

在指定時間點執行 使用 ISO 8601

如:2011-03-11T12:13:14

<timerEventDefinition>
    <timeDate>2011-03-11T12:13:14</timeDate>
</timerEventDefinition>

 

timeDuration

指定定時器之前要等待多長時間, timeDuration可以設置為timerEventDefinition的子元素。 使用ISO 8601規定的格式 (由BPMN 2.0規定)。示例(等待10天)。

<timerEventDefinition>
    <timeDuration>P10D</timeDuration>
</timerEventDefinition>

 

timeCycle

指定重復執行的間隔, 可以用來定期啟動流程實例,或為超時時間發送多個提醒。 timeCycle元素可以使用兩種格式。第一種是 ISO 8601 標准的格式。示例(重復3次,每次間隔10小時)

<timerEventDefinition>
    <timeCycle>R3/PT10H</timeCycle>
</timerEventDefinition>

cron格式

如每月月初啟動一個任務

0 0 2 1 * ?

xml

<?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">
  <process id="中間捕獲事件測試" name="time_evet_test3" isExecutable="true">
    <startEvent id="startEvent1"></startEvent>
    <userTask id="sid-93595C49-26DA-44F2-9BDE-AFCA9023FEC7" name="用戶下單" flowable:assignee="大力強">
      <extensionElements>
        <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
      </extensionElements>
    </userTask>
    <sequenceFlow id="sid-AF8BE282-7418-4245-8A59-D4A8AACCFB12" sourceRef="startEvent1" targetRef="sid-93595C49-26DA-44F2-9BDE-AFCA9023FEC7"></sequenceFlow>
    <intermediateCatchEvent id="sid-05568350-8BAC-4EEF-840D-D39156EDD500">
      <timerEventDefinition>
        <timeDuration>P5M</timeDuration>
      </timerEventDefinition>
    </intermediateCatchEvent>
    <sequenceFlow id="sid-AAEBC31E-FC1D-450F-B61B-9392C20DB6A0" sourceRef="sid-93595C49-26DA-44F2-9BDE-AFCA9023FEC7" targetRef="sid-05568350-8BAC-4EEF-840D-D39156EDD500"></sequenceFlow>
    <userTask id="sid-C91EBC29-619B-4F16-AC79-690ED1C4AE3E" name="生成發貨單" flowable:assignee="大力強2">
      <extensionElements>
        <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
      </extensionElements>
    </userTask>
    <endEvent id="sid-7A2E09EE-59BF-49DA-9205-84E719AAA2D1"></endEvent>
    <sequenceFlow id="sid-A6A4D364-551C-4B12-B577-34A442980D26" sourceRef="sid-C91EBC29-619B-4F16-AC79-690ED1C4AE3E" targetRef="sid-7A2E09EE-59BF-49DA-9205-84E719AAA2D1"></sequenceFlow>
    <sequenceFlow id="sid-6EB75DA4-8C43-487F-8708-7634BA340DA7" name="延遲5分鍾" sourceRef="sid-05568350-8BAC-4EEF-840D-D39156EDD500" targetRef="sid-C91EBC29-619B-4F16-AC79-690ED1C4AE3E"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_中間捕獲事件測試">
    <bpmndi:BPMNPlane bpmnElement="中間捕獲事件測試" id="BPMNPlane_中間捕獲事件測試">
      <bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
        <omgdc:Bounds height="30.0" width="30.0" x="90.0" y="150.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-93595C49-26DA-44F2-9BDE-AFCA9023FEC7" id="BPMNShape_sid-93595C49-26DA-44F2-9BDE-AFCA9023FEC7">
        <omgdc:Bounds height="80.0" width="100.0" x="165.0" y="125.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-05568350-8BAC-4EEF-840D-D39156EDD500" id="BPMNShape_sid-05568350-8BAC-4EEF-840D-D39156EDD500">
        <omgdc:Bounds height="31.0" width="31.0" x="330.0" y="149.5"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-C91EBC29-619B-4F16-AC79-690ED1C4AE3E" id="BPMNShape_sid-C91EBC29-619B-4F16-AC79-690ED1C4AE3E">
        <omgdc:Bounds height="80.0" width="100.0" x="450.0" y="125.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-7A2E09EE-59BF-49DA-9205-84E719AAA2D1" id="BPMNShape_sid-7A2E09EE-59BF-49DA-9205-84E719AAA2D1">
        <omgdc:Bounds height="28.0" width="28.0" x="630.0" y="151.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sid-AAEBC31E-FC1D-450F-B61B-9392C20DB6A0" id="BPMNEdge_sid-AAEBC31E-FC1D-450F-B61B-9392C20DB6A0">
        <omgdi:waypoint x="264.94999999999357" y="165.1906488549618"></omgdi:waypoint>
        <omgdi:waypoint x="330.0000092162973" y="165.43893173323616"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-AF8BE282-7418-4245-8A59-D4A8AACCFB12" id="BPMNEdge_sid-AF8BE282-7418-4245-8A59-D4A8AACCFB12">
        <omgdi:waypoint x="119.94999848995758" y="165.0"></omgdi:waypoint>
        <omgdi:waypoint x="165.0" y="165.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-A6A4D364-551C-4B12-B577-34A442980D26" id="BPMNEdge_sid-A6A4D364-551C-4B12-B577-34A442980D26">
        <omgdi:waypoint x="549.9499999999827" y="165.0"></omgdi:waypoint>
        <omgdi:waypoint x="630.0" y="165.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-6EB75DA4-8C43-487F-8708-7634BA340DA7" id="BPMNEdge_sid-6EB75DA4-8C43-487F-8708-7634BA340DA7">
        <omgdi:waypoint x="361.9499176799087" y="165.44805221616247"></omgdi:waypoint>
        <omgdi:waypoint x="449.99999999999545" y="165.16217532467533"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
View Code

中間捕獲信號事件

說明 

當到達此節點,會等待接收到信號才會完成下一個節點

api接收信號來源

//把信號發送給全局所有訂閱的處理器(廣播語義)。
runtimeService.signalEventReceived(String signalName);
//只把信息發送給指定的執行。
runtimeService.signalEventReceived(String signalName, String executionId)

查詢訂閱了事件的執行流 對應表select * from act_ru_event_subscr

 List<Execution> executions = runtimeService.createExecutionQuery()
      .signalEventSubscriptionName("start")
      .list();

通過拋出中間信號事件接收信號來源

查詢訂閱了事件的執行流 對應表select * from act_ru_event_subscr 也是觀察這張表 里面有type區分

發起人填表后會開啟並行網關,但是研發這條線會等待.等產品組長拋出審批信號后才會到研發負責人並行審批

 

 

信號源的作用范圍

主要看我們定義信號設置接收范圍

 

 

拋出中間信號事件 

說明

信號中間Throwing事件用於拋出信號,當流程到達該事件時,會直接拋出信號,其他引用了相同信號的信號Catching事件會被觸發。

設計

 

消息中間捕獲事件

說明

消息中間捕獲事件跟中間信號事件很相似,中間信號事件支持廣播,消息事件只支持一對一

通過api接口消息源

查詢訂閱了此消息的執行流相關表:select * from act_ru_event_subscr

// 查詢任務
        Execution execution = runtimeService.createExecutionQuery()
                .messageEventSubscriptionName("msg")
                .processInstanceId(pi.getId())
                .singleResult();

發布消息

 

 設計

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM