版权声明:转载注明出处就OK的说,有些东西会转载,都会注明的说= =如果有冒犯麻烦见谅 https://blog.csdn.net/Pan1458689676/article/details/82662203

StartEvent组件

  • StartEvent组件

    • StartEvent总述
    • StartEvent(普通)
    • TimerStartEvent(定时器启动组件)
      • 注意【摘自官网】:

        • TiemCycle【按时间循环启动】
        • TimeDate【定时启动】
        • TimeDuration【延时启动】

StartEvent总述

StartEvent分为五种,第一种为普通StartEvent,第二种为带定时器的SatrtEvent,第三种为接收消息的StartEvent,第四种为带错误信息的StartEvent这种最为特殊,下文会详细来说。第五种为带信号的StartEvent从这篇文章主要讲工作流的StartEvent。下面开始逐一讲解。

StartEvent(普通)

StartEvent为一个流程的起始点,我们来看看官网是如何描述的:
StartEvent(普通)对应的XML内代码如下

<startEvent id="startevent1" name="Start"></startEvent>

activiti:initiator="initiator"

这个部分,activiti:initiator:在进程启动时将存储用户标识的变量名称。以initiator为UserId。一般设置这个是和form联用的【emmm我是不会去用的】。这里就是告诉大家可以用xml打开bpmn的代码有这个属性设置。通过eclipse插件可以直接如下图这样设置。

老规矩跑起来试试



可以看到已经进了历史数据表了【因为已经启动了start这个实例被执行了就进入了历史表】
starter:以这种方式设置就会是starter
participant:任务办理人,建议以流程变量的方式指定
candidate:候选人,组任务那块可以指定

TimerStartEvent(定时器启动组件)

打开允许异步操作

TimerStartEvent对应的XML内代码如下【未做任何设置的TimerStartEvent】

<startEvent id="timerstartevent1" name="Timer start"><timerEventDefinition></timerEventDefinition>
</startEvent>

计时器启动事件用于在给定时间创建流程实例。它既可以用于应该只启动一次的进程,也可以用于应该以特定时间间隔启动的进程。

注意【摘自官网】:

  • 子流程不能有TimerStartEvent。
  • 一旦部署了进程,就会安排TimerStartEvent。不需要调用startProcessInstanceByXXX方法,虽然调用start process方法不受限制,并且会在startProcessInstanceByXXX Invocation时再启动一个进程。
  • 当部署具有TimerStartEvent的新版本的进程时,将删除与先前计时器对应的作业。原因是通常不希望自动启动此旧版本流程的新流程实例。

使用的方式呢就是使用如下三个标签控制定时器开始事件。接下来是demo了。

TiemCycle【按时间循环启动】

流程图总览【UserTask以及后面的完全没有设置,for流程完整性和方便查看运行效果】

流程图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:activiti="http://activiti.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="TiemCycle"><process id="TiemCycle" name="TiemCycle" isExecutable="true"><endEvent id="endevent1" name="End"></endEvent><userTask id="usertask1" name="User Task"></userTask><sequenceFlow id="flow2" sourceRef="usertask1" targetRef="endevent1"></sequenceFlow><startEvent id="timerstartevent1" name="Timer start"><timerEventDefinition><timeCycle>0/5 * * * * ?</timeCycle></timerEventDefinition></startEvent><sequenceFlow id="flow3" sourceRef="timerstartevent1" targetRef="usertask1"></sequenceFlow></process><bpmndi:BPMNDiagram id="BPMNDiagram_TiemCycle"><bpmndi:BPMNPlane bpmnElement="TiemCycle" id="BPMNPlane_TiemCycle"><bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1"><omgdc:Bounds height="35.0" width="35.0" x="490.0" y="170.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1"><omgdc:Bounds height="55.0" width="105.0" x="290.0" y="160.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="timerstartevent1" id="BPMNShape_timerstartevent1"><omgdc:Bounds height="35.0" width="35.0" x="160.0" y="170.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2"><omgdi:waypoint x="395.0" y="187.0"></omgdi:waypoint><omgdi:waypoint x="490.0" y="187.0"></omgdi:waypoint></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3"><omgdi:waypoint x="195.0" y="187.0"></omgdi:waypoint><omgdi:waypoint x="290.0" y="187.0"></omgdi:waypoint></bpmndi:BPMNEdge></bpmndi:BPMNPlane></bpmndi:BPMNDiagram>
</definitions>

corn 表达式


这个代表每分钟的第0秒开始每五秒钟调用一次。【生成Corn表达式的网站,不必刻意去记忆 http://cron.qqe2.com/】

【ISO 8601方式】重复5次,每次间隔10小时

<timeCycle activiti:endDate="2019-09-12T21:42:00+00:00">R5/PT10H</timeCycle>
<timeCycle>R5/2019-10-07T12:00/PT10H</timeCycle>//这个是开始时间

测试代码

@Test
public void TiemCycleTest() throws InterruptedException{Deployment deployment = repositoryService.createDeployment()/.name("StartEventNormal").addClasspathResource("bpmn/TiemCycle.bpmn").addClasspathResource("bpmn/TiemCycle.png").deploy();long dataCount = runtimeService.createProcessInstanceQuery().count();System.out.println("sleep前流程实例数量:" + dataCount);Thread.sleep(60000L);dataCount = runtimeService.createProcessInstanceQuery().count();System.out.println("sleep后流程实例数量:" + dataCount);
}


【上图Name见谅一下不想再去截图了。复制代码快了】

TimeDate【定时启动】

流程图总览


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:activiti="http://activiti.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.activiti.org/test"><process id="myProcess" name="My process" isExecutable="true"><startEvent id="timerstartevent1" name="Timer start"><timerEventDefinition><timeDate>2018-09-12T17:20:00</timeDate></timerEventDefinition></startEvent><userTask id="usertask1" name="User Task"></userTask><endEvent id="endevent1" name="End"></endEvent><sequenceFlow id="flow1" sourceRef="timerstartevent1" targetRef="usertask1"></sequenceFlow><sequenceFlow id="flow2" sourceRef="usertask1" targetRef="endevent1"></sequenceFlow></process><bpmndi:BPMNDiagram id="BPMNDiagram_myProcess"><bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess"><bpmndi:BPMNShape bpmnElement="timerstartevent1" id="BPMNShape_timerstartevent1"><omgdc:Bounds height="35.0" width="35.0" x="210.0" y="240.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1"><omgdc:Bounds height="55.0" width="105.0" x="360.0" y="230.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1"><omgdc:Bounds height="35.0" width="35.0" x="590.0" y="240.0"></omgdc:Bounds></bpmndi:BPMNShape><bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1"><omgdi:waypoint x="245.0" y="257.0"></omgdi:waypoint><omgdi:waypoint x="360.0" y="257.0"></omgdi:waypoint></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2"><omgdi:waypoint x="465.0" y="257.0"></omgdi:waypoint><omgdi:waypoint x="590.0" y="257.0"></omgdi:waypoint></bpmndi:BPMNEdge></bpmndi:BPMNPlane></bpmndi:BPMNDiagram>
</definitions>

时间的格式是有要求的

直接部署流程五点20时查看是否已经自动生成流程实例

@Test
public void TimeDate() throws InterruptedException{Deployment deployment = repositoryService.createDeployment().name("TimeDate").addClasspathResource("bpmn/TimeDate.bpmn").addClasspathResource("bpmn/TimeDate.png").deploy();long dataCount = runtimeService.createProcessInstanceQuery().count();System.out.println("sleep前流程实例数量:" + dataCount);Thread.sleep(60000L);//dataCount = runtimeService.createProcessInstanceQuery().count();System.out.println("sleep后流程实例数量:" + dataCount);
}


【单元测试线程代码运行完则退出,不会像主线程一样等待子线程退出而退出, 会直接退出。Junit单元测试不支持多线程。主线程退出,子线程也会退出。】

TimeDuration【延时启动】

微改一下,这里稍微偷懒一下啦。

@Test
public void TimeDate() throws InterruptedException{Deployment deployment = repositoryService.createDeployment().name("TimeDate").addClasspathResource("bpmn/TimeDate.bpmn").addClasspathResource("bpmn/TimeDate.png").deploy();long dataCount = runtimeService.createProcessInstanceQuery().count();System.out.println("sleep前流程实例数量:" + dataCount);Thread.sleep(5000L);dataCount = runtimeService.createProcessInstanceQuery().count();System.out.println("sleep后流程实例数量:" + dataCount);
}

Activiti 6.x【6】StartEvent(上)相关推荐

  1. activiti绘制流程图,线上显示文字,审批过的节点添加审批人的名字

    最有时间优化了一下activiti的绘制图片工具类,主要用于在领导审批的时候展示的漂亮,直接上代码吧, /** 放在我们的业务代码中,穿个流程实例id进来,返回一个字符数组,然后该怎么处理你们应该知道 ...

  2. activiti:initiator的作用及其使用

    (转载)activiti:initiator的作用及其使用 原文链接:http://www.kafeitu.me/activiti/2012/09/14/activiti-initiator.html ...

  3. activiti学习资料--initiator的作用及其使用

    activiti:initiator的作用及其使用 1.场景模拟 以kft-activiti-demo中的请假流程为例,操作流程: 用户A申请请假 领导B驳回 任务流转到"调整请假信息&qu ...

  4. Activiti 6.x【11】IntermediateEvent

    版权声明:转载注明出处就OK的说,有些东西会转载,都会注明的说= =如果有冒犯麻烦见谅 https://blog.csdn.net/Pan1458689676/article/details/8272 ...

  5. 一、activiti工作流(workflow)入门介绍

    activiti官方网站(官网通常很卡,不建议看,直接看我教程就行) http://www.activiti.org/ eclipse离线安装activiti插件并下载教程 https://downl ...

  6. 集成新版(5.17+)Activiti Modeler与Rest服务

    声明: 此教程适合Activiti 5.17+版本. 本博客所涉及的内容均可在kft-activiti-demo中找到. 在线demo可以访问 http://demo.kafeitu.me:8080/ ...

  7. 基于Activiti的流程应用开发平台JSAAS-WF V5.3

    第1章 产品概述及体系架构 1.1.概述 红迅JSAAS-WF工作流平台V5是广州红迅软件有限公司面向合作伙伴以及有IT运维团队中大型企业提供新一代的流程管理产品,它基于流行的JAVA开源技术上构建, ...

  8. Activiti笔记

    第一章 认识Activiti Activiti七大Service接口 Activiti与jBPM5比较 注意 第2章 Acitiviti与BPMN 20规范 启动事件与结束事件 空启动事件 定时启动事 ...

  9. Activiti配置

    用户的脑洞永远都在碾压我的技术水平,最近又有用户想在流程上大做文章.于是,我只能重翻Activiti 6的用户手册和API,从头记录并分享一下. Activiti 6的User Guide目录为htt ...

  10. 工作流学习2(书本)

    1.流程引擎的创建. 1.1.ProcessEngineConfiguration的buildProcessEngine方法 使用ProcessEngineConfiguration的create方法 ...

最新文章

  1. Linux内核设计与实现学习笔记目录
  2. 实验四 Windows程序设计
  3. MySQL之在储存过程中使用表名为变量
  4. const 指针_C语言学习日记(11)——const与指针
  5. 【2019.08.31】2019银川网络赛(2018银川现场赛)
  6. C#——后台管理端多级菜单的生成方式
  7. matlab学习笔记第七章——常微分方程(ODE)的数值解
  8. 重拾web开发-DIV+CSS基础(总结)
  9. 草根学Python(十四) 一步一步了解正则表达式
  10. ffmpeg可支持的编码器、解码器、封装格式、网络协议
  11. php1108脱机使用,电脑打印机脱机怎么重新连接
  12. 完整版第四方Oreo易支付源码+28K易支付源码
  13. python 卡方检验批量筛选_用python进行列联表卡方检验
  14. 【正则表达式】网页上敏感词过滤背后的原理你知道吗?
  15. Linux系统U盘怎么格式化,Linux下对U盘的分区与格式化
  16. 太阳直射点纬度计算公式_干货 | 正午太阳高度公式及其应用!
  17. SpringMVC中的MultipartResolver,LocaleResolver
  18. 一文带你深入了解Linux IIO 子系统
  19. 使用Bitmap生成透明底图,并保存到本地SD卡中
  20. Jmeter使用BeanShell取样器调用Python脚本

热门文章

  1. C++ Primer 第九章 顺序容器
  2. java23中设计模式——结构模式——Composite(组合)
  3. 二分搜索 2015百度之星初赛1 HDOJ 5248 序列变换
  4. Java从零开始学四十六(Junit)
  5. 【转】大端模式与小端模式、网络字节顺序与主机字节顺序 (经典)
  6. 2018-08-12 长大
  7. 链表节点的删除(删除重复无序节点)
  8. AlphaGo的原理
  9. Gitlab VM安装过程
  10. 提高oracle查询效率