gpt4 book ai didi

java - activiti中的中间信号抛出和捕获事件不起作用

转载 作者:行者123 更新时间:2023-11-30 06:08:00 24 4
gpt4 key购买 nike

我尝试在以下 bpd 中抛出并捕获名为“alert”的信号,如 activiti 用户指南中所述。但我无法触发附加到信号捕获事件的服务事件。 enter image description here

我尝试通过java触发信号

runtimeService.signalEventReceived("alert");

但是信号没有被捕获。以下代码确保有一个监听器附加到进程已启动

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

附上完整的 bpd:

<?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="Examples">
<signal id="alertSignal" name="alert" activiti:scope="processInstance"></signal>
<message id="actionOnAcceptedLR" name="actionOnAcceptedLR"></message>
<process id="demoProcessDefinition" name="demoProcessDefinition" isExecutable="true">
<subProcess id="subprocess1" name="Sub Process">
<startEvent id="startevent2" name="Start"></startEvent>
<eventBasedGateway id="eventgateway1" name="Event Gateway"></eventBasedGateway>
<sequenceFlow id="flow2" sourceRef="startevent2" targetRef="eventgateway1"></sequenceFlow>
<intermediateCatchEvent id="messageintermediatecatchevent1" name="MessageCatchEvent">
<messageEventDefinition messageRef="actionOnAcceptedLR"></messageEventDefinition>
</intermediateCatchEvent>
<sequenceFlow id="flow3" sourceRef="eventgateway1" targetRef="messageintermediatecatchevent1"></sequenceFlow>
<intermediateCatchEvent id="timerintermediatecatchevent1" name="TimerCatchEvent">
<timerEventDefinition>
<timeDuration>P01D</timeDuration>
</timerEventDefinition>
</intermediateCatchEvent>
<sequenceFlow id="flow4" sourceRef="eventgateway1" targetRef="timerintermediatecatchevent1"></sequenceFlow>
<serviceTask id="servicetask1" name="Service Task" activiti:expression="${processDelegate.dummy1(execution)}"></serviceTask>
<sequenceFlow id="flow5" sourceRef="messageintermediatecatchevent1" targetRef="servicetask1"></sequenceFlow>
<serviceTask id="servicetask2" name="Service Task" activiti:expression="${processDelegate.dummy2(execution)}"></serviceTask>
<sequenceFlow id="flow7" sourceRef="timerintermediatecatchevent1" targetRef="servicetask2"></sequenceFlow>
<endEvent id="endevent2" name="End"></endEvent>
<sequenceFlow id="flow8" sourceRef="servicetask2" targetRef="endevent2"></sequenceFlow>
<intermediateCatchEvent id="signalintermediatecatchevent1" name="SignalCatchEvent">
<signalEventDefinition signalRef="alertSignal"></signalEventDefinition>
</intermediateCatchEvent>
<sequenceFlow id="flow11" sourceRef="signalintermediatecatchevent1" targetRef="servicetask3"></sequenceFlow>
<serviceTask id="servicetask3" name="Service Task" activiti:expression="${processDelegate.dummy2(execution)}"></serviceTask>
<sequenceFlow id="flow12" sourceRef="servicetask3" targetRef="endevent4"></sequenceFlow>
<endEvent id="endevent4" name="End"></endEvent>
<intermediateThrowEvent id="signalintermediatethrowevent1" name="SignalThrowEvent">
<signalEventDefinition signalRef="alertSignal"></signalEventDefinition>
</intermediateThrowEvent>
<sequenceFlow id="flow13" sourceRef="servicetask1" targetRef="signalintermediatethrowevent1"></sequenceFlow>
</subProcess>
<startEvent id="startevent1" name="Start"></startEvent>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="subprocess1"></sequenceFlow>
<endEvent id="endevent3" name="End"></endEvent>
<sequenceFlow id="flow9" sourceRef="subprocess1" targetRef="endevent3"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_demoProcessDefinition">
<bpmndi:BPMNPlane bpmnElement="demoProcessDefinition" id="BPMNPlane_demoProcessDefinition">
<bpmndi:BPMNShape bpmnElement="subprocess1" id="BPMNShape_subprocess1">
<omgdc:Bounds height="381.0" width="561.0" x="180.0" y="120.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="startevent2" id="BPMNShape_startevent2">
<omgdc:Bounds height="35.0" width="35.0" x="210.0" y="230.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="eventgateway1" id="BPMNShape_eventgateway1">
<omgdc:Bounds height="40.0" width="40.0" x="320.0" y="227.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="messageintermediatecatchevent1" id="BPMNShape_messageintermediatecatchevent1">
<omgdc:Bounds height="35.0" width="35.0" x="430.0" y="160.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="timerintermediatecatchevent1" id="BPMNShape_timerintermediatecatchevent1">
<omgdc:Bounds height="35.0" width="35.0" x="430.0" y="310.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
<omgdc:Bounds height="55.0" width="105.0" x="510.0" y="150.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="servicetask2" id="BPMNShape_servicetask2">
<omgdc:Bounds height="55.0" width="105.0" x="510.0" y="300.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
<omgdc:Bounds height="35.0" width="35.0" x="660.0" y="310.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="signalintermediatecatchevent1" id="BPMNShape_signalintermediatecatchevent1">
<omgdc:Bounds height="35.0" width="35.0" x="244.0" y="388.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="servicetask3" id="BPMNShape_servicetask3">
<omgdc:Bounds height="55.0" width="105.0" x="326.0" y="378.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent4" id="BPMNShape_endevent4">
<omgdc:Bounds height="35.0" width="35.0" x="476.0" y="388.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="signalintermediatethrowevent1" id="BPMNShape_signalintermediatethrowevent1">
<omgdc:Bounds height="35.0" width="35.0" x="650.0" y="160.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="99.0" y="293.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent3" id="BPMNShape_endevent3">
<omgdc:Bounds height="35.0" width="35.0" x="780.0" y="290.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="245.0" y="247.0"></omgdi:waypoint>
<omgdi:waypoint x="320.0" y="247.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="340.0" y="227.0"></omgdi:waypoint>
<omgdi:waypoint x="447.0" y="195.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="340.0" y="267.0"></omgdi:waypoint>
<omgdi:waypoint x="447.0" y="310.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
<omgdi:waypoint x="465.0" y="177.0"></omgdi:waypoint>
<omgdi:waypoint x="510.0" y="177.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
<omgdi:waypoint x="465.0" y="327.0"></omgdi:waypoint>
<omgdi:waypoint x="510.0" y="327.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
<omgdi:waypoint x="615.0" y="327.0"></omgdi:waypoint>
<omgdi:waypoint x="660.0" y="327.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
<omgdi:waypoint x="279.0" y="405.0"></omgdi:waypoint>
<omgdi:waypoint x="326.0" y="405.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
<omgdi:waypoint x="431.0" y="405.0"></omgdi:waypoint>
<omgdi:waypoint x="476.0" y="405.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
<omgdi:waypoint x="615.0" y="177.0"></omgdi:waypoint>
<omgdi:waypoint x="650.0" y="177.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="134.0" y="310.0"></omgdi:waypoint>
<omgdi:waypoint x="180.0" y="310.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
<omgdi:waypoint x="741.0" y="310.0"></omgdi:waypoint>
<omgdi:waypoint x="780.0" y="307.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

我在这里做错了什么吗?我尝试将 catch 事件放入子进程中或从子进程中取出,以检查此问题是否是由于任何范围问题引起的。仍然没有运气。真的被困在这里了。

最佳答案

您不能在同一进程中创建信号抛出事件信号捕获事件。这没有任何意义,一个进程怎么能同时抛出并捕获同一事件。将您的流程分成两个单独的流程,或者至少将其中一个流程放入子流程中。

关于java - activiti中的中间信号抛出和捕获事件不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40677257/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com