JBoss 系列四十二:jBPM5示例之 Signal Event

在BPM流程中经常需要事件信号,只有当流程中某信号被触发时,流程继续执行,jBPM5中使用Signal Event来完成这一需求,如下为SignalEvent流程:

JBoss 系列四十二:jBPM5示例之 Signal Event_第1张图片

如图,Signal Event节点Payment位于Gateway之前,我们通过Payment传递一个变量到流程,流程在执行问Process Subscription Request节点后等待Payment信号被触发,信号触发后流程继续执行;当通过Payment传递一个变量的值大于或等于100时则The payment is enough,Create Subscription Data节点执行,否则,The payment is not enough,Send Message节点,和Refund Money节点执行。

  • SignalEvent流程运行代码:https://github.com/kylinsoong/.../SignalEventStart.java
  • SignalEvent流程:https://github.com/kylinsoong/.../singleEventProcessWithData.bpmn
运行org.jbpm.quickstarts.event.SignalEventStart可以执行SignalEvent流程,SignalEventStart代码如下:

package org.jbpm.quickstarts.event;

import org.drools.runtime.StatefulKnowledgeSession;
import org.jbpm.quickstarts.QuickStartBase;

public class SignalEventStart extends QuickStartBase {

	public static void main(String[] args) {
		new SignalEventStart().test();
	}

	public void test() {
		StatefulKnowledgeSession ksession = createKnowledgeSession("quickstarts/singleEventProcessWithData.bpmn");
		ksession.startProcess("org.jbpm.quickstarts.singleeventprocesswithdata");
		ksession.signalEvent("payment", 90);
		ksession.dispose();
	}

}

SignalEvent流程执行结果输出如下:

Process Subscription Request
Send Message
Refund Money

如上运行结果是由于我们通过Payment信号节点传递的payment为90小于100,所以Send Message节点,和Refund Money节点被执行。

你可能感兴趣的:(jboss,jbpm,event,Signal,BPM,JBPM5)