bpmn-elements 5.1.3 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +322 -0
- package/README.md +9 -3
- package/dist/index.js +71 -39
- package/dist/src/Api.js +77 -76
- package/dist/src/Context.js +169 -164
- package/dist/src/Environment.js +90 -102
- package/dist/src/EventBroker.js +89 -88
- package/dist/src/ExtensionsMapper.js +2 -2
- package/dist/src/MessageFormatter.js +164 -95
- package/dist/src/Scripts.js +6 -2
- package/dist/src/Timers.js +4 -6
- package/dist/src/activity/Activity.js +1108 -901
- package/dist/src/activity/ActivityExecution.js +342 -297
- package/dist/src/activity/Dummy.js +3 -3
- package/dist/src/definition/Definition.js +498 -444
- package/dist/src/definition/DefinitionExecution.js +722 -409
- package/dist/src/error/Errors.js +17 -7
- package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
- package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
- package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
- package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
- package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
- package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
- package/dist/src/events/BoundaryEvent.js +180 -144
- package/dist/src/events/EndEvent.js +18 -23
- package/dist/src/events/IntermediateCatchEvent.js +44 -58
- package/dist/src/events/IntermediateThrowEvent.js +18 -23
- package/dist/src/events/StartEvent.js +109 -94
- package/dist/src/flows/Association.js +94 -101
- package/dist/src/flows/MessageFlow.js +86 -103
- package/dist/src/flows/SequenceFlow.js +172 -184
- package/dist/src/gateways/EventBasedGateway.js +88 -84
- package/dist/src/gateways/ExclusiveGateway.js +13 -16
- package/dist/src/gateways/InclusiveGateway.js +11 -14
- package/dist/src/gateways/ParallelGateway.js +11 -14
- package/dist/src/getPropertyValue.js +34 -34
- package/dist/src/io/BpmnIO.js +31 -0
- package/dist/src/io/EnvironmentDataObject.js +33 -29
- package/dist/src/io/EnvironmentDataStore.js +52 -0
- package/dist/src/io/EnvironmentDataStoreReference.js +52 -0
- package/dist/src/io/InputOutputSpecification.js +177 -168
- package/dist/src/io/Properties.js +252 -0
- package/dist/src/messageHelper.js +1 -1
- package/dist/src/process/Process.js +433 -359
- package/dist/src/process/ProcessExecution.js +744 -645
- package/dist/src/shared.js +3 -6
- package/dist/src/tasks/CallActivity.js +160 -0
- package/dist/src/tasks/LoopCharacteristics.js +309 -330
- package/dist/src/tasks/ReceiveTask.js +233 -182
- package/dist/src/tasks/ScriptTask.js +35 -41
- package/dist/src/tasks/ServiceImplementation.js +13 -20
- package/dist/src/tasks/ServiceTask.js +82 -75
- package/dist/src/tasks/SignalTask.js +97 -93
- package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/dist/src/tasks/SubProcess.js +195 -175
- package/dist/src/tasks/Task.js +17 -19
- package/index.js +8 -0
- package/package.json +16 -15
- package/src/Api.js +65 -59
- package/src/Context.js +142 -132
- package/src/Environment.js +88 -100
- package/src/EventBroker.js +67 -68
- package/src/ExtensionsMapper.js +2 -2
- package/src/MessageFormatter.js +132 -74
- package/src/Timers.js +4 -4
- package/src/activity/Activity.js +916 -757
- package/src/activity/ActivityExecution.js +293 -247
- package/src/activity/Dummy.js +2 -2
- package/src/definition/Definition.js +436 -401
- package/src/definition/DefinitionExecution.js +603 -343
- package/src/error/Errors.js +11 -6
- package/src/eventDefinitions/CancelEventDefinition.js +164 -121
- package/src/eventDefinitions/CompensateEventDefinition.js +158 -124
- package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
- package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
- package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
- package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
- package/src/eventDefinitions/LinkEventDefinition.js +160 -129
- package/src/eventDefinitions/MessageEventDefinition.js +178 -121
- package/src/eventDefinitions/SignalEventDefinition.js +162 -106
- package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
- package/src/eventDefinitions/TimerEventDefinition.js +202 -167
- package/src/events/BoundaryEvent.js +156 -115
- package/src/events/EndEvent.js +15 -18
- package/src/events/IntermediateCatchEvent.js +40 -44
- package/src/events/IntermediateThrowEvent.js +15 -18
- package/src/events/StartEvent.js +84 -50
- package/src/flows/Association.js +98 -113
- package/src/flows/MessageFlow.js +81 -97
- package/src/flows/SequenceFlow.js +145 -163
- package/src/gateways/EventBasedGateway.js +75 -68
- package/src/gateways/ExclusiveGateway.js +8 -13
- package/src/gateways/InclusiveGateway.js +8 -13
- package/src/gateways/ParallelGateway.js +8 -13
- package/src/getPropertyValue.js +34 -33
- package/src/io/BpmnIO.js +20 -0
- package/src/io/EnvironmentDataObject.js +29 -18
- package/src/io/EnvironmentDataStore.js +33 -0
- package/src/io/EnvironmentDataStoreReference.js +33 -0
- package/src/io/InputOutputSpecification.js +154 -157
- package/src/io/Properties.js +199 -0
- package/src/process/Process.js +374 -333
- package/src/process/ProcessExecution.js +606 -554
- package/src/shared.js +1 -5
- package/src/tasks/CallActivity.js +130 -0
- package/src/tasks/LoopCharacteristics.js +290 -289
- package/src/tasks/ReceiveTask.js +174 -107
- package/src/tasks/ScriptTask.js +27 -30
- package/src/tasks/ServiceImplementation.js +13 -18
- package/src/tasks/ServiceTask.js +67 -60
- package/src/tasks/SignalTask.js +77 -52
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +184 -157
- package/src/tasks/Task.js +15 -19
|
@@ -2,134 +2,172 @@ import getPropertyValue from '../getPropertyValue';
|
|
|
2
2
|
import {brokerSafeId} from '../shared';
|
|
3
3
|
import {cloneContent, shiftParent} from '../messageHelper';
|
|
4
4
|
|
|
5
|
+
const completedSymbol = Symbol.for('completed');
|
|
6
|
+
const messageQSymbol = Symbol.for('messageQ');
|
|
7
|
+
const executeMessageSymbol = Symbol.for('executeMessage');
|
|
8
|
+
const referenceElementSymbol = Symbol.for('referenceElement');
|
|
9
|
+
const referenceInfoSymbol = Symbol.for('reference');
|
|
10
|
+
|
|
5
11
|
export default function EscalationEventDefinition(activity, eventDefinition) {
|
|
6
|
-
const {id, broker, environment, isThrowing
|
|
12
|
+
const {id, broker, environment, isThrowing} = activity;
|
|
7
13
|
const {type, behaviour = {}} = eventDefinition;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const source = {
|
|
17
|
-
id,
|
|
18
|
-
type,
|
|
19
|
-
reference: {...reference, referenceType: 'escalate'},
|
|
20
|
-
execute: isThrowing ? executeThrow : executeCatch,
|
|
14
|
+
|
|
15
|
+
this.id = id;
|
|
16
|
+
this.type = type;
|
|
17
|
+
|
|
18
|
+
const reference = this.reference = {
|
|
19
|
+
name: 'anonymous',
|
|
20
|
+
...behaviour.escalationRef,
|
|
21
|
+
referenceType: 'escalate',
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
this.isThrowing = isThrowing;
|
|
25
|
+
this.activity = activity;
|
|
26
|
+
this.broker = broker;
|
|
27
|
+
this.logger = environment.Logger(type.toLowerCase());
|
|
28
|
+
|
|
29
|
+
const referenceElement = this[referenceElementSymbol] = reference.id && activity.getActivityById(reference.id);
|
|
30
|
+
if (!isThrowing) {
|
|
31
|
+
this[completedSymbol] = false;
|
|
32
|
+
const referenceId = referenceElement ? referenceElement.id : 'anonymous';
|
|
33
|
+
const messageQueueName = `${reference.referenceType}-${brokerSafeId(id)}-${brokerSafeId(referenceId)}-q`;
|
|
34
|
+
this[messageQSymbol] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
|
|
35
|
+
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {durable: true, priority: 400});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
24
38
|
|
|
25
|
-
|
|
26
|
-
let completed;
|
|
39
|
+
const proto = EscalationEventDefinition.prototype;
|
|
27
40
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
41
|
+
Object.defineProperty(proto, 'executionId', {
|
|
42
|
+
get() {
|
|
43
|
+
const message = this[executeMessageSymbol];
|
|
44
|
+
return message && message.content.executionId;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
31
47
|
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
proto.execute = function execute(executeMessage) {
|
|
49
|
+
return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
|
|
50
|
+
};
|
|
34
51
|
|
|
35
|
-
|
|
52
|
+
proto.executeCatch = function executeCatch(executeMessage) {
|
|
53
|
+
this[executeMessageSymbol] = executeMessage;
|
|
54
|
+
this[completedSymbol] = false;
|
|
36
55
|
|
|
37
|
-
|
|
56
|
+
const executeContent = executeMessage.content;
|
|
57
|
+
const {executionId, parent} = executeContent;
|
|
38
58
|
|
|
39
|
-
|
|
59
|
+
const info = this[referenceInfoSymbol] = this._getReferenceInfo(executeMessage);
|
|
60
|
+
const broker = this.broker;
|
|
61
|
+
this[messageQSymbol].consume(this._onCatchMessage.bind(this), {
|
|
62
|
+
noAck: true,
|
|
63
|
+
consumerTag: `_onescalate-${executionId}`,
|
|
64
|
+
});
|
|
40
65
|
|
|
41
|
-
|
|
66
|
+
if (this[completedSymbol]) return;
|
|
42
67
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
escalation: {...referenceMessage},
|
|
48
|
-
});
|
|
68
|
+
broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
|
|
69
|
+
noAck: true,
|
|
70
|
+
consumerTag: `_api-${executionId}`,
|
|
71
|
+
});
|
|
49
72
|
|
|
50
|
-
|
|
51
|
-
if (getPropertyValue(message, 'content.message.id') !== referenceMessage.id) return;
|
|
73
|
+
this._debug(`expect ${info.description}`);
|
|
52
74
|
|
|
53
|
-
|
|
54
|
-
|
|
75
|
+
const waitContent = cloneContent(executeContent, {
|
|
76
|
+
executionId: parent.executionId,
|
|
77
|
+
parent: shiftParent(parent),
|
|
78
|
+
escalation: {...info.message},
|
|
79
|
+
});
|
|
80
|
+
waitContent.parent = shiftParent(parent);
|
|
55
81
|
|
|
56
|
-
|
|
82
|
+
broker.publish('event', 'activity.wait', waitContent);
|
|
83
|
+
};
|
|
57
84
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
message: {...output},
|
|
62
|
-
executionId: parentExecutionId,
|
|
63
|
-
parent: shiftParent(executeMessage.content.parent),
|
|
64
|
-
}, {type: 'catch'});
|
|
85
|
+
proto.executeThrow = function executeThrow(executeMessage) {
|
|
86
|
+
const executeContent = executeMessage.content;
|
|
87
|
+
const {executionId, parent} = executeContent;
|
|
65
88
|
|
|
66
|
-
|
|
67
|
-
|
|
89
|
+
const info = this._getReferenceInfo(executeMessage);
|
|
90
|
+
this.logger.debug(`<${executionId} (${this.activity.id})> escalate ${info.description}`);
|
|
68
91
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
case 'discard': {
|
|
77
|
-
completed = true;
|
|
78
|
-
stop();
|
|
79
|
-
return broker.publish('execution', 'execute.discard', {...messageContent});
|
|
80
|
-
}
|
|
81
|
-
case 'stop': {
|
|
82
|
-
stop();
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
92
|
+
const broker = this.broker;
|
|
93
|
+
const throwContent = cloneContent(executeContent, {
|
|
94
|
+
executionId: parent.executionId,
|
|
95
|
+
message: info.message,
|
|
96
|
+
state: 'throw',
|
|
97
|
+
});
|
|
98
|
+
throwContent.parent = shiftParent(parent);
|
|
87
99
|
|
|
88
|
-
|
|
89
|
-
broker.cancel(`_api-${executionId}`);
|
|
90
|
-
broker.cancel(`_onescalate-${executionId}`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
100
|
+
broker.publish('event', 'activity.escalate', throwContent, {type: 'escalate', delegate: true});
|
|
93
101
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const {executionId, parent} = messageContent;
|
|
97
|
-
const parentExecutionId = parent && parent.executionId;
|
|
102
|
+
return broker.publish('execution', 'execute.completed', cloneContent(executeContent));
|
|
103
|
+
};
|
|
98
104
|
|
|
99
|
-
|
|
105
|
+
proto._onCatchMessage = function onCatchMessage(routingKey, message) {
|
|
106
|
+
const info = this[referenceInfoSymbol];
|
|
107
|
+
if (getPropertyValue(message, 'content.message.id') !== info.message.id) return;
|
|
100
108
|
|
|
101
|
-
|
|
109
|
+
const output = message.content.message;
|
|
110
|
+
this[completedSymbol] = true;
|
|
102
111
|
|
|
103
|
-
|
|
104
|
-
...cloneContent(messageContent),
|
|
105
|
-
executionId: parentExecutionId,
|
|
106
|
-
parent: shiftParent(parent),
|
|
107
|
-
message: {...referenceMessage},
|
|
108
|
-
state: 'throw',
|
|
109
|
-
}, {type: 'escalate', delegate: true});
|
|
112
|
+
this._stop();
|
|
110
113
|
|
|
111
|
-
|
|
112
|
-
}
|
|
114
|
+
this._debug(`caught ${info.description}`);
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
const executeContent = this[executeMessageSymbol].content;
|
|
117
|
+
const {parent, ...content} = executeContent;
|
|
118
|
+
const catchContent = cloneContent(content, {
|
|
119
|
+
message: {...output},
|
|
120
|
+
executionId: parent.executionId,
|
|
121
|
+
});
|
|
122
|
+
catchContent.parent = shiftParent(parent);
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
124
|
+
const broker = this.broker;
|
|
125
|
+
broker.publish('event', 'activity.catch', catchContent, {type: 'catch'});
|
|
125
126
|
|
|
126
|
-
|
|
127
|
+
return broker.publish('execution', 'execute.completed', cloneContent(executeContent, {output, state: 'catch'}));
|
|
128
|
+
};
|
|
127
129
|
|
|
128
|
-
|
|
130
|
+
proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
131
|
+
switch (message.properties.type) {
|
|
132
|
+
case 'escalate': {
|
|
133
|
+
return this._onCatchMessage(routingKey, message);
|
|
134
|
+
}
|
|
135
|
+
case 'discard': {
|
|
136
|
+
this[completedSymbol] = true;
|
|
137
|
+
this._stop();
|
|
138
|
+
return this.broker.publish('execution', 'execute.discard', cloneContent(this[executeMessageSymbol].content));
|
|
139
|
+
}
|
|
140
|
+
case 'stop': {
|
|
141
|
+
this._stop();
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
129
144
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
proto._stop = function stop() {
|
|
148
|
+
const broker = this.broker, executionId = this.executionId;
|
|
149
|
+
broker.cancel(`_api-${executionId}`);
|
|
150
|
+
broker.cancel(`_onescalate-${executionId}`);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
proto._getReferenceInfo = function getReferenceInfo(message) {
|
|
154
|
+
const referenceElement = this[referenceElementSymbol];
|
|
155
|
+
if (!referenceElement) {
|
|
156
|
+
return {
|
|
157
|
+
message: {...this.reference},
|
|
158
|
+
description: 'anonymous escalation',
|
|
159
|
+
};
|
|
134
160
|
}
|
|
135
|
-
|
|
161
|
+
|
|
162
|
+
const result = {
|
|
163
|
+
message: referenceElement.resolve(message),
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
result.description = `${result.message.name} <${result.message.id}>`;
|
|
167
|
+
|
|
168
|
+
return result;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
proto._debug = function debug(msg) {
|
|
172
|
+
this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
|
|
173
|
+
};
|
|
@@ -1,113 +1,145 @@
|
|
|
1
|
-
import {cloneContent, unshiftParent, shiftParent} from '../messageHelper';
|
|
1
|
+
import {cloneContent, unshiftParent, shiftParent, cloneParent} from '../messageHelper';
|
|
2
|
+
|
|
3
|
+
const completedSymbol = Symbol.for('completed');
|
|
4
|
+
const executeMessageSymbol = Symbol.for('executeMessage');
|
|
5
|
+
const stoppedSymbol = Symbol.for('stopped');
|
|
2
6
|
|
|
3
7
|
export default function EventDefinitionExecution(activity, eventDefinitions, completedRoutingKey = 'execute.completed') {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
this.id = activity.id;
|
|
9
|
+
this.activity = activity;
|
|
10
|
+
this.broker = activity.broker;
|
|
11
|
+
this.eventDefinitions = eventDefinitions;
|
|
12
|
+
this.completedRoutingKey = completedRoutingKey;
|
|
13
|
+
this[completedSymbol] = false;
|
|
14
|
+
this[stoppedSymbol] = false;
|
|
15
|
+
this[executeMessageSymbol] = null;
|
|
16
|
+
}
|
|
7
17
|
|
|
8
|
-
|
|
18
|
+
const proto = EventDefinitionExecution.prototype;
|
|
9
19
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
Object.defineProperty(proto, 'completed', {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get() {
|
|
23
|
+
return this[completedSymbol];
|
|
24
|
+
},
|
|
25
|
+
});
|
|
16
26
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
Object.defineProperty(proto, 'stopped', {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get() {
|
|
30
|
+
return this[stoppedSymbol];
|
|
31
|
+
},
|
|
32
|
+
});
|
|
21
33
|
|
|
22
|
-
|
|
34
|
+
proto.execute = function execute(executeMessage) {
|
|
35
|
+
const content = executeMessage.content;
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
parentExecutionId = messageExecutionId;
|
|
27
|
-
parentExecutionContent = executeContent;
|
|
37
|
+
if (content.isDefinitionScope) return this._executeDefinition(executeMessage);
|
|
38
|
+
if (!content.isRootScope) return;
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
broker.subscribeTmp('api', `activity.*.${parentExecutionId}`, onApiMessage, {noAck: true, consumerTag: apiConsumerTag, priority: 300});
|
|
40
|
+
const broker = this.broker;
|
|
31
41
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
if (isRedelivered) return;
|
|
36
|
-
|
|
37
|
-
for (let index = 0; index < eventDefinitions.length; ++index) {
|
|
38
|
-
if (completed) break;
|
|
39
|
-
if (stopped) break;
|
|
40
|
-
|
|
41
|
-
const ed = eventDefinitions[index];
|
|
42
|
-
const executionId = `${messageExecutionId}_${index}`;
|
|
43
|
-
|
|
44
|
-
logger.debug(`<${messageExecutionId} (${id})> start event definition ${ed.type}, index ${index}`);
|
|
45
|
-
|
|
46
|
-
broker.publish('execution', 'execute.start', {
|
|
47
|
-
...cloneContent(parentExecutionContent),
|
|
48
|
-
isRootScope: undefined,
|
|
49
|
-
type: ed.type,
|
|
50
|
-
executionId,
|
|
51
|
-
isDefinitionScope: true,
|
|
52
|
-
index,
|
|
53
|
-
parent,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
42
|
+
this[executeMessageSymbol] = executeMessage;
|
|
43
|
+
const executionId = content.executionId;
|
|
56
44
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
45
|
+
broker.subscribeTmp('execution', 'execute.#', this._onExecuteMessage.bind(this), {
|
|
46
|
+
noAck: true,
|
|
47
|
+
consumerTag: '_eventdefinition-execution-execute-tag',
|
|
48
|
+
priority: 300,
|
|
49
|
+
});
|
|
50
|
+
broker.subscribeTmp('api', `activity.*.${executionId}`, this._onApiMessage.bind(this), {
|
|
51
|
+
noAck: true,
|
|
52
|
+
consumerTag: '_eventdefinition-execution-api-tag',
|
|
53
|
+
priority: 300,
|
|
54
|
+
});
|
|
66
55
|
|
|
67
|
-
|
|
68
|
-
const {correlationId} = message.properties;
|
|
69
|
-
switch (routingKey) {
|
|
70
|
-
case 'execute.completed': {
|
|
71
|
-
stop();
|
|
72
|
-
if (message.content.isDefinitionScope) return complete();
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
case 'execute.discard': {
|
|
76
|
-
if (message.content.isDefinitionScope) {
|
|
77
|
-
logger.debug(`<${message.content.executionId} (${id})> event definition ${message.content.type} discarded, index ${message.content.index}`);
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
stop();
|
|
81
|
-
logger.debug(`<${message.content.executionId} (${id})> event definition parent execution discarded`);
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
56
|
+
broker.publish('execution', 'execute.update', cloneContent(content, {preventComplete: true}));
|
|
85
57
|
|
|
86
|
-
|
|
87
|
-
const content = cloneContent(message.content);
|
|
88
|
-
completed = true;
|
|
58
|
+
if (executeMessage.fields.redelivered) return;
|
|
89
59
|
|
|
90
|
-
|
|
60
|
+
const parent = unshiftParent(content.parent, content);
|
|
61
|
+
const eventDefinitions = this.eventDefinitions;
|
|
91
62
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
isRootScope: true,
|
|
96
|
-
parent: shiftParent(content.parent),
|
|
97
|
-
}, {correlationId});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
63
|
+
for (let index = 0; index < eventDefinitions.length; ++index) {
|
|
64
|
+
if (this[completedSymbol]) break;
|
|
65
|
+
if (this[stoppedSymbol]) break;
|
|
100
66
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
ed.execute(executeMessage);
|
|
106
|
-
}
|
|
67
|
+
const ed = eventDefinitions[index];
|
|
68
|
+
const edExecutionId = `${executionId}_${index}`;
|
|
69
|
+
|
|
70
|
+
this._debug(executionId, `start event definition ${ed.type}, index ${index}`);
|
|
107
71
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
72
|
+
const edContent = cloneContent(content, {
|
|
73
|
+
isRootScope: undefined,
|
|
74
|
+
type: ed.type,
|
|
75
|
+
executionId: edExecutionId,
|
|
76
|
+
isDefinitionScope: true,
|
|
77
|
+
index,
|
|
78
|
+
});
|
|
79
|
+
edContent.parent = cloneParent(parent);
|
|
80
|
+
|
|
81
|
+
broker.publish('execution', 'execute.start', edContent);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
proto._onApiMessage = function onApiMessage(_, message) {
|
|
86
|
+
const messageType = message.properties.type;
|
|
87
|
+
switch (messageType) {
|
|
88
|
+
case 'stop':
|
|
89
|
+
case 'discard':
|
|
90
|
+
return this._stop();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
|
|
95
|
+
switch (routingKey) {
|
|
96
|
+
case 'execute.completed': {
|
|
97
|
+
this._stop();
|
|
98
|
+
if (message.content.isDefinitionScope) return this._complete(message);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case 'execute.discard': {
|
|
102
|
+
const {executionId, isDefinitionScope} = message.content;
|
|
103
|
+
if (isDefinitionScope) {
|
|
104
|
+
this._debug(executionId, `event definition ${message.content.type} discarded, index ${message.content.index}`);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
this._stop();
|
|
108
|
+
this._debug(executionId, 'event definition parent execution discarded');
|
|
109
|
+
break;
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
|
-
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
proto._complete = function complete(message) {
|
|
115
|
+
const {executionId, type, index, parent} = message.content;
|
|
116
|
+
this[completedSymbol] = true;
|
|
117
|
+
|
|
118
|
+
this._debug(executionId, `event definition ${type} completed, index ${index}`);
|
|
119
|
+
|
|
120
|
+
const completeContent = cloneContent(message.content, {
|
|
121
|
+
executionId: this[executeMessageSymbol].content.executionId,
|
|
122
|
+
isRootScope: true,
|
|
123
|
+
});
|
|
124
|
+
completeContent.parent = shiftParent(parent);
|
|
125
|
+
|
|
126
|
+
this.broker.publish('execution', this.completedRoutingKey, completeContent, {correlationId: message.properties.correlationId});
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
proto._executeDefinition = function executeDefinition(message) {
|
|
130
|
+
const {executionId, index} = message.content;
|
|
131
|
+
const ed = this.eventDefinitions[index];
|
|
132
|
+
if (!ed) return this.activity.logger.warn(`<${executionId} (${this.id})> found no event definition on index ${index}`);
|
|
133
|
+
this._debug(executionId, `execute event definition ${ed.type}, index ${index}`);
|
|
134
|
+
ed.execute(message);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
proto._stop = function stop() {
|
|
138
|
+
this[stoppedSymbol] = true;
|
|
139
|
+
this.broker.cancel('_eventdefinition-execution-execute-tag');
|
|
140
|
+
this.broker.cancel('_eventdefinition-execution-api-tag');
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
proto._debug = function debug(executionId, msg) {
|
|
144
|
+
this.activity.logger.debug(`<${executionId} (${this.id})> ${msg}`);
|
|
145
|
+
};
|