Flowable消息邊界事件


layout: pages
title: Flowable消息邊界事件
date: 2018.09.28
tags: workflow


1.消息邊界事件可以做什么

可以插件式的為流程添加節(jié)點,說起來有點抽象我們看例子。

2.如何設置一個消息邊界事件

  • ①首先在Message definitions中定義消息,如下圖:


    image.png

    image.png
  • ②然后編輯流程
    設置消息邊界,設置的時候就可以選擇①定義好的消息了(此處有很多人會疑惑消息邊界事件的引用如何使用,其實是配合①的定義來使用)定義后的流程如圖所示:
    image.png

    附件:messageEventboundary.bpmn20.xml

3.如何使用一個消息邊界事件

    @Autowired
    private RuntimeService runtimeService;

    @Autowired
    private TaskService taskService;

    @Autowired
    private HistoryService historyService;

  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageEventboundary");
        //啟動流程 到達任務1
        List<Task> tasks = taskService.createTaskQuery().list();
        assert tasks.size() == 1;
        assert "任務1".equals(tasks.get(0).getName());

        //觸發(fā)邊界事件
        Execution execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("邊界測試").singleResult();
        runtimeService.messageEventReceived("邊界測試", execution.getId());

        //到達邊界事件
        List<Task> eventTasks = taskService.createTaskQuery().list();
        assert eventTasks.size() == 1;
        assert "邊界事件".equals(eventTasks.get(0).getName());

        //完成邊界事件
        taskService.complete(eventTasks.get(0).getId());

        assert null != historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult().getEndTime();

關于消息邊界事件的使用應該就是這些,感覺并沒有吃透flowable的邊界事件的用途,接下來的博客會對邊界事件的其它形式(異常邊界事件,定時邊界事件等)做一個跟深入的研究,也歡迎大家留言探討。

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容