bpmn-elements 7.0.0 → 8.1.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 +23 -0
- package/dist/src/Context.js +50 -40
- package/dist/src/Environment.js +39 -19
- package/dist/src/MessageFormatter.js +11 -11
- package/dist/src/activity/Activity.js +106 -106
- package/dist/src/activity/ActivityExecution.js +37 -37
- package/dist/src/activity/Message.js +2 -2
- package/dist/src/activity/Signal.js +2 -2
- package/dist/src/definition/Definition.js +50 -50
- package/dist/src/definition/DefinitionExecution.js +114 -125
- package/dist/src/eventDefinitions/CancelEventDefinition.js +16 -16
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +24 -24
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +26 -26
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +20 -20
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +14 -14
- package/dist/src/eventDefinitions/LinkEventDefinition.js +15 -15
- package/dist/src/eventDefinitions/MessageEventDefinition.js +23 -23
- package/dist/src/eventDefinitions/SignalEventDefinition.js +24 -24
- package/dist/src/eventDefinitions/TimerEventDefinition.js +76 -53
- package/dist/src/events/BoundaryEvent.js +67 -38
- package/dist/src/events/EndEvent.js +3 -3
- package/dist/src/events/IntermediateCatchEvent.js +3 -3
- package/dist/src/events/IntermediateThrowEvent.js +3 -3
- package/dist/src/events/StartEvent.js +9 -9
- package/dist/src/flows/Association.js +7 -7
- package/dist/src/flows/MessageFlow.js +9 -9
- package/dist/src/flows/SequenceFlow.js +7 -7
- package/dist/src/gateways/EventBasedGateway.js +11 -11
- package/dist/src/io/InputOutputSpecification.js +4 -4
- package/dist/src/io/Properties.js +9 -9
- package/dist/src/process/Process.js +64 -61
- package/dist/src/process/ProcessExecution.js +93 -90
- package/dist/src/tasks/ReceiveTask.js +16 -16
- package/dist/src/tasks/SubProcess.js +16 -18
- package/package.json +15 -16
- package/src/Context.js +48 -40
- package/src/Environment.js +48 -20
- package/src/EventBroker.js +1 -1
- package/src/MessageFormatter.js +11 -11
- package/src/activity/Activity.js +99 -100
- package/src/activity/ActivityExecution.js +35 -35
- package/src/activity/Message.js +1 -1
- package/src/activity/Signal.js +1 -1
- package/src/definition/Definition.js +51 -50
- package/src/definition/DefinitionExecution.js +111 -113
- package/src/eventDefinitions/CancelEventDefinition.js +16 -16
- package/src/eventDefinitions/CompensateEventDefinition.js +25 -24
- package/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
- package/src/eventDefinitions/ErrorEventDefinition.js +26 -26
- package/src/eventDefinitions/EscalationEventDefinition.js +20 -20
- package/src/eventDefinitions/EventDefinitionExecution.js +14 -14
- package/src/eventDefinitions/LinkEventDefinition.js +15 -15
- package/src/eventDefinitions/MessageEventDefinition.js +23 -23
- package/src/eventDefinitions/SignalEventDefinition.js +24 -24
- package/src/eventDefinitions/TimerEventDefinition.js +61 -44
- package/src/events/BoundaryEvent.js +53 -36
- package/src/events/EndEvent.js +3 -3
- package/src/events/IntermediateCatchEvent.js +3 -3
- package/src/events/IntermediateThrowEvent.js +3 -3
- package/src/events/StartEvent.js +9 -9
- package/src/flows/Association.js +7 -7
- package/src/flows/MessageFlow.js +9 -9
- package/src/flows/SequenceFlow.js +7 -7
- package/src/gateways/EventBasedGateway.js +11 -11
- package/src/io/BpmnIO.js +5 -1
- package/src/io/InputOutputSpecification.js +4 -4
- package/src/io/Properties.js +9 -9
- package/src/process/Process.js +62 -58
- package/src/process/ProcessExecution.js +86 -88
- package/src/tasks/ReceiveTask.js +16 -16
- package/src/tasks/SubProcess.js +16 -16
package/src/activity/Activity.js
CHANGED
|
@@ -7,19 +7,19 @@ import {Formatter} from '../MessageFormatter';
|
|
|
7
7
|
import {cloneContent, cloneParent, cloneMessage} from '../messageHelper';
|
|
8
8
|
import {makeErrorFromMessage, ActivityError} from '../error/Errors';
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
10
|
+
const kActivityDef = Symbol.for('activityDefinition');
|
|
11
|
+
const kBpmnIo = Symbol.for('bpmnIo');
|
|
12
|
+
const kConsuming = Symbol.for('consuming');
|
|
13
|
+
const kCounters = Symbol.for('counters');
|
|
14
|
+
const kEventDefinitions = Symbol.for('eventDefinitions');
|
|
15
|
+
const kExec = Symbol.for('exec');
|
|
16
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
17
|
+
const kExtensions = Symbol.for('extensions');
|
|
18
|
+
const kFlags = Symbol.for('flags');
|
|
19
|
+
const kFlows = Symbol.for('flows');
|
|
20
|
+
const kFormatter = Symbol.for('formatter');
|
|
21
|
+
const kMessageHandlers = Symbol.for('messageHandlers');
|
|
22
|
+
const kStateMessage = Symbol.for('stateMessage');
|
|
23
23
|
|
|
24
24
|
export default Activity;
|
|
25
25
|
|
|
@@ -27,7 +27,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
27
27
|
const {id, type = 'activity', name, behaviour = {}} = activityDef;
|
|
28
28
|
const {attachedTo: attachedToRef, eventDefinitions} = behaviour;
|
|
29
29
|
|
|
30
|
-
this[
|
|
30
|
+
this[kActivityDef] = activityDef;
|
|
31
31
|
this.id = id;
|
|
32
32
|
this.type = type;
|
|
33
33
|
this.name = name;
|
|
@@ -37,7 +37,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
37
37
|
this.logger = context.environment.Logger(type.toLowerCase());
|
|
38
38
|
this.environment = context.environment;
|
|
39
39
|
this.context = context;
|
|
40
|
-
this[
|
|
40
|
+
this[kCounters] = {
|
|
41
41
|
taken: 0,
|
|
42
42
|
discarded: 0,
|
|
43
43
|
};
|
|
@@ -60,7 +60,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
60
60
|
const inboundAssociations = context.getInboundAssociations(id);
|
|
61
61
|
const inboundTriggers = attachedToActivity ? [attachedToActivity] : inboundSequenceFlows.slice();
|
|
62
62
|
const outboundSequenceFlows = context.getOutboundSequenceFlows(id);
|
|
63
|
-
const flows = this[
|
|
63
|
+
const flows = this[kFlows] = {
|
|
64
64
|
inboundSequenceFlows,
|
|
65
65
|
inboundAssociations,
|
|
66
66
|
inboundJoinFlows: [],
|
|
@@ -71,7 +71,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
71
71
|
|
|
72
72
|
const isForCompensation = !!behaviour.isForCompensation;
|
|
73
73
|
const isParallelJoin = activityDef.isParallelGateway && flows.inboundSequenceFlows.length > 1;
|
|
74
|
-
this[
|
|
74
|
+
this[kFlags] = {
|
|
75
75
|
isEnd: flows.outboundSequenceFlows.length === 0,
|
|
76
76
|
isStart: flows.inboundSequenceFlows.length === 0 && !attachedTo && !behaviour.triggeredByEvent && !isForCompensation,
|
|
77
77
|
isSubProcess: activityDef.isSubProcess,
|
|
@@ -82,9 +82,9 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
82
82
|
isParallelJoin,
|
|
83
83
|
isThrowing: activityDef.isThrowing,
|
|
84
84
|
};
|
|
85
|
-
this[
|
|
85
|
+
this[kExec] = {};
|
|
86
86
|
|
|
87
|
-
this[
|
|
87
|
+
this[kMessageHandlers] = {
|
|
88
88
|
onInbound: isParallelJoin ? this._onJoinInbound.bind(this) : this._onInbound.bind(this),
|
|
89
89
|
onRunMessage: this._onRunMessage.bind(this),
|
|
90
90
|
onApiMessage: this._onApiMessage.bind(this),
|
|
@@ -104,7 +104,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
this[
|
|
107
|
+
this[kEventDefinitions] = eventDefinitions && eventDefinitions.map((ed) => new ed.Behaviour(this, ed, this.context));
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const proto = Activity.prototype;
|
|
@@ -112,29 +112,29 @@ const proto = Activity.prototype;
|
|
|
112
112
|
Object.defineProperty(proto, 'counters', {
|
|
113
113
|
enumerable: true,
|
|
114
114
|
get() {
|
|
115
|
-
return {...this[
|
|
115
|
+
return {...this[kCounters]};
|
|
116
116
|
},
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
Object.defineProperty(proto, 'execution', {
|
|
120
120
|
enumerable: true,
|
|
121
121
|
get() {
|
|
122
|
-
return this[
|
|
122
|
+
return this[kExec].execution;
|
|
123
123
|
},
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
Object.defineProperty(proto, 'executionId', {
|
|
127
127
|
enumerable: true,
|
|
128
128
|
get() {
|
|
129
|
-
return this[
|
|
129
|
+
return this[kExec].executionId;
|
|
130
130
|
},
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
Object.defineProperty(proto, 'bpmnIo', {
|
|
134
134
|
enumerable: true,
|
|
135
135
|
get() {
|
|
136
|
-
if (
|
|
137
|
-
const bpmnIo = this[
|
|
136
|
+
if (kBpmnIo in this) return this[kBpmnIo];
|
|
137
|
+
const bpmnIo = this[kBpmnIo] = new BpmnIO(this, this.context);
|
|
138
138
|
return bpmnIo;
|
|
139
139
|
},
|
|
140
140
|
});
|
|
@@ -142,8 +142,8 @@ Object.defineProperty(proto, 'bpmnIo', {
|
|
|
142
142
|
Object.defineProperty(proto, 'extensions', {
|
|
143
143
|
enumerable: true,
|
|
144
144
|
get() {
|
|
145
|
-
if (
|
|
146
|
-
const extensions = this[
|
|
145
|
+
if (kExtensions in this) return this[kExtensions];
|
|
146
|
+
const extensions = this[kExtensions] = this.context.loadExtensions(this);
|
|
147
147
|
return extensions;
|
|
148
148
|
},
|
|
149
149
|
});
|
|
@@ -151,11 +151,11 @@ Object.defineProperty(proto, 'extensions', {
|
|
|
151
151
|
Object.defineProperty(proto, 'formatter', {
|
|
152
152
|
enumerable: true,
|
|
153
153
|
get() {
|
|
154
|
-
let formatter = this[
|
|
154
|
+
let formatter = this[kFormatter];
|
|
155
155
|
if (formatter) return formatter;
|
|
156
156
|
|
|
157
157
|
const broker = this.broker;
|
|
158
|
-
formatter = this[
|
|
158
|
+
formatter = this[kFormatter] = new Formatter({
|
|
159
159
|
id: this.id,
|
|
160
160
|
broker,
|
|
161
161
|
logger: this.logger,
|
|
@@ -167,7 +167,7 @@ Object.defineProperty(proto, 'formatter', {
|
|
|
167
167
|
Object.defineProperty(proto, 'isRunning', {
|
|
168
168
|
enumerable: true,
|
|
169
169
|
get() {
|
|
170
|
-
if (!this[
|
|
170
|
+
if (!this[kConsuming]) return false;
|
|
171
171
|
return !!this.status;
|
|
172
172
|
},
|
|
173
173
|
});
|
|
@@ -175,66 +175,66 @@ Object.defineProperty(proto, 'isRunning', {
|
|
|
175
175
|
Object.defineProperty(proto, 'outbound', {
|
|
176
176
|
enumerable: true,
|
|
177
177
|
get() {
|
|
178
|
-
return this[
|
|
178
|
+
return this[kFlows].outboundSequenceFlows;
|
|
179
179
|
},
|
|
180
180
|
});
|
|
181
181
|
|
|
182
182
|
Object.defineProperty(proto, 'inbound', {
|
|
183
183
|
enumerable: true,
|
|
184
184
|
get() {
|
|
185
|
-
return this[
|
|
185
|
+
return this[kFlows].inboundSequenceFlows;
|
|
186
186
|
},
|
|
187
187
|
});
|
|
188
188
|
|
|
189
189
|
Object.defineProperty(proto, 'isEnd', {
|
|
190
190
|
enumerable: true,
|
|
191
191
|
get() {
|
|
192
|
-
return this[
|
|
192
|
+
return this[kFlags].isEnd;
|
|
193
193
|
},
|
|
194
194
|
});
|
|
195
195
|
Object.defineProperty(proto, 'isStart', {
|
|
196
196
|
enumerable: true,
|
|
197
197
|
get() {
|
|
198
|
-
return this[
|
|
198
|
+
return this[kFlags].isStart;
|
|
199
199
|
},
|
|
200
200
|
});
|
|
201
201
|
Object.defineProperty(proto, 'isSubProcess', {
|
|
202
202
|
enumerable: true,
|
|
203
203
|
get() {
|
|
204
|
-
return this[
|
|
204
|
+
return this[kFlags].isSubProcess;
|
|
205
205
|
},
|
|
206
206
|
});
|
|
207
207
|
|
|
208
208
|
Object.defineProperty(proto, 'isMultiInstance', {
|
|
209
209
|
enumerable: true,
|
|
210
210
|
get() {
|
|
211
|
-
return this[
|
|
211
|
+
return this[kFlags].isMultiInstance;
|
|
212
212
|
},
|
|
213
213
|
});
|
|
214
214
|
|
|
215
215
|
Object.defineProperty(proto, 'isThrowing', {
|
|
216
216
|
enumerable: true,
|
|
217
217
|
get() {
|
|
218
|
-
return this[
|
|
218
|
+
return this[kFlags].isThrowing;
|
|
219
219
|
},
|
|
220
220
|
});
|
|
221
221
|
Object.defineProperty(proto, 'isForCompensation', {
|
|
222
222
|
enumerable: true,
|
|
223
223
|
get() {
|
|
224
|
-
return this[
|
|
224
|
+
return this[kFlags].isForCompensation;
|
|
225
225
|
},
|
|
226
226
|
});
|
|
227
227
|
Object.defineProperty(proto, 'triggeredByEvent', {
|
|
228
228
|
enumerable: true,
|
|
229
229
|
get() {
|
|
230
|
-
return this[
|
|
230
|
+
return this[kActivityDef].triggeredByEvent;
|
|
231
231
|
},
|
|
232
232
|
});
|
|
233
233
|
|
|
234
234
|
Object.defineProperty(proto, 'attachedTo', {
|
|
235
235
|
enumerable: true,
|
|
236
236
|
get() {
|
|
237
|
-
const attachedToId = this[
|
|
237
|
+
const attachedToId = this[kFlags].attachedTo;
|
|
238
238
|
if (!attachedToId) return null;
|
|
239
239
|
return this.getActivityById(attachedToId);
|
|
240
240
|
},
|
|
@@ -243,12 +243,12 @@ Object.defineProperty(proto, 'attachedTo', {
|
|
|
243
243
|
Object.defineProperty(proto, 'eventDefinitions', {
|
|
244
244
|
enumerable: true,
|
|
245
245
|
get() {
|
|
246
|
-
return this[
|
|
246
|
+
return this[kEventDefinitions];
|
|
247
247
|
},
|
|
248
248
|
});
|
|
249
249
|
|
|
250
250
|
proto.activate = function activate() {
|
|
251
|
-
if (this[
|
|
251
|
+
if (this[kFlags].isForCompensation) return;
|
|
252
252
|
return this._consumeInbound();
|
|
253
253
|
};
|
|
254
254
|
|
|
@@ -260,7 +260,7 @@ proto.deactivate = function deactivate() {
|
|
|
260
260
|
|
|
261
261
|
proto.init = function init(initContent) {
|
|
262
262
|
const id = this.id;
|
|
263
|
-
const exec = this[
|
|
263
|
+
const exec = this[kExec];
|
|
264
264
|
const executionId = exec.initExecutionId = exec.initExecutionId || getUniqueId(id);
|
|
265
265
|
this.logger.debug(`<${id}> initialized with executionId <${executionId}>`);
|
|
266
266
|
this._publishEvent('init', this._createMessage({...initContent, executionId}));
|
|
@@ -270,7 +270,7 @@ proto.run = function run(runContent) {
|
|
|
270
270
|
const id = this.id;
|
|
271
271
|
if (this.isRunning) throw new Error(`activity <${id}> is already running`);
|
|
272
272
|
|
|
273
|
-
const exec = this[
|
|
273
|
+
const exec = this[kExec];
|
|
274
274
|
const executionId = exec.executionId = exec.initExecutionId || getUniqueId(id);
|
|
275
275
|
exec.initExecutionId = null;
|
|
276
276
|
|
|
@@ -291,10 +291,10 @@ proto.recover = function recover(state) {
|
|
|
291
291
|
|
|
292
292
|
this.stopped = state.stopped;
|
|
293
293
|
this.status = state.status;
|
|
294
|
-
const exec = this[
|
|
294
|
+
const exec = this[kExec];
|
|
295
295
|
exec.executionId = state.executionId;
|
|
296
296
|
|
|
297
|
-
this[
|
|
297
|
+
this[kCounters] = {...this[kCounters], ...state.counters};
|
|
298
298
|
|
|
299
299
|
if (state.execution) {
|
|
300
300
|
exec.execution = new ActivityExecution(this, this.context).recover(state.execution);
|
|
@@ -306,7 +306,7 @@ proto.recover = function recover(state) {
|
|
|
306
306
|
};
|
|
307
307
|
|
|
308
308
|
proto.resume = function resume() {
|
|
309
|
-
if (this[
|
|
309
|
+
if (this[kConsuming]) {
|
|
310
310
|
throw new Error(`cannot resume running activity <${this.id}>`);
|
|
311
311
|
}
|
|
312
312
|
if (!this.status) return this.activate();
|
|
@@ -322,24 +322,24 @@ proto.resume = function resume() {
|
|
|
322
322
|
|
|
323
323
|
proto.discard = function discard(discardContent) {
|
|
324
324
|
if (!this.status) return this._runDiscard(discardContent);
|
|
325
|
-
const execution = this[
|
|
325
|
+
const execution = this[kExec].execution;
|
|
326
326
|
if (execution && !execution.completed) return execution.discard();
|
|
327
327
|
|
|
328
328
|
this._deactivateRunConsumers();
|
|
329
329
|
const broker = this.broker;
|
|
330
330
|
broker.getQueue('run-q').purge();
|
|
331
|
-
broker.publish('run', 'run.discard', cloneContent(this[
|
|
331
|
+
broker.publish('run', 'run.discard', cloneContent(this[kStateMessage].content));
|
|
332
332
|
this._consumeRunQ();
|
|
333
333
|
};
|
|
334
334
|
|
|
335
335
|
proto.stop = function stop() {
|
|
336
|
-
if (!this[
|
|
336
|
+
if (!this[kConsuming]) return;
|
|
337
337
|
return this.getApi().stop();
|
|
338
338
|
};
|
|
339
339
|
|
|
340
340
|
proto.next = function next() {
|
|
341
341
|
if (!this.environment.settings.step) return;
|
|
342
|
-
const stateMessage = this[
|
|
342
|
+
const stateMessage = this[kStateMessage];
|
|
343
343
|
if (!stateMessage) return;
|
|
344
344
|
if (this.status === 'executing') return false;
|
|
345
345
|
if (this.status === 'formatting') return false;
|
|
@@ -353,13 +353,13 @@ proto.shake = function shake() {
|
|
|
353
353
|
};
|
|
354
354
|
|
|
355
355
|
proto.evaluateOutbound = function evaluateOutbound(fromMessage, discardRestAtTake, callback) {
|
|
356
|
-
return this[
|
|
356
|
+
return this[kFlows].outboundEvaluator.evaluate(fromMessage, discardRestAtTake, callback);
|
|
357
357
|
};
|
|
358
358
|
|
|
359
359
|
proto.getState = function getState() {
|
|
360
360
|
const msg = this._createMessage();
|
|
361
361
|
|
|
362
|
-
const exec = this[
|
|
362
|
+
const exec = this[kExec];
|
|
363
363
|
return {
|
|
364
364
|
...msg,
|
|
365
365
|
executionId: exec.executionId,
|
|
@@ -372,9 +372,9 @@ proto.getState = function getState() {
|
|
|
372
372
|
};
|
|
373
373
|
|
|
374
374
|
proto.getApi = function getApi(message) {
|
|
375
|
-
const execution = this[
|
|
375
|
+
const execution = this[kExec].execution;
|
|
376
376
|
if (execution && !execution.completed) return execution.getApi(message);
|
|
377
|
-
return ActivityApi(this.broker, message || this[
|
|
377
|
+
return ActivityApi(this.broker, message || this[kStateMessage]);
|
|
378
378
|
};
|
|
379
379
|
|
|
380
380
|
proto.getActivityById = function getActivityById(elementId) {
|
|
@@ -382,7 +382,7 @@ proto.getActivityById = function getActivityById(elementId) {
|
|
|
382
382
|
};
|
|
383
383
|
|
|
384
384
|
proto._runDiscard = function runDiscard(discardContent) {
|
|
385
|
-
const exec = this[
|
|
385
|
+
const exec = this[kExec];
|
|
386
386
|
const executionId = exec.executionId = exec.initExecutionId || getUniqueId(this.id);
|
|
387
387
|
exec.initExecutionId = null;
|
|
388
388
|
|
|
@@ -398,7 +398,7 @@ proto._discardRun = function discardRun() {
|
|
|
398
398
|
const status = this.status;
|
|
399
399
|
if (!status) return;
|
|
400
400
|
|
|
401
|
-
const execution = this[
|
|
401
|
+
const execution = this[kExec].execution;
|
|
402
402
|
if (execution && !execution.completed) return;
|
|
403
403
|
switch (status) {
|
|
404
404
|
case 'executing':
|
|
@@ -411,7 +411,7 @@ proto._discardRun = function discardRun() {
|
|
|
411
411
|
if (this.extensions) this.extensions.deactivate();
|
|
412
412
|
const broker = this.broker;
|
|
413
413
|
broker.getQueue('run-q').purge();
|
|
414
|
-
broker.publish('run', 'run.discard', cloneContent(this[
|
|
414
|
+
broker.publish('run', 'run.discard', cloneContent(this[kStateMessage].content));
|
|
415
415
|
this._consumeRunQ();
|
|
416
416
|
};
|
|
417
417
|
|
|
@@ -423,21 +423,21 @@ proto._shakeOutbound = function shakeOutbound(sourceMessage) {
|
|
|
423
423
|
const broker = this.broker;
|
|
424
424
|
this.broker.publish('api', 'activity.shake.start', message.content, {persistent: false, type: 'shake'});
|
|
425
425
|
|
|
426
|
-
if (this[
|
|
426
|
+
if (this[kFlags].isEnd) {
|
|
427
427
|
return broker.publish('event', 'activity.shake.end', message.content, {persistent: false, type: 'shake'});
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
-
for (const flow of this[
|
|
430
|
+
for (const flow of this[kFlows].outboundSequenceFlows) flow.shake(message);
|
|
431
431
|
};
|
|
432
432
|
|
|
433
433
|
proto._consumeInbound = function consumeInbound() {
|
|
434
434
|
if (this.status) return;
|
|
435
435
|
const inboundQ = this.broker.getQueue('inbound-q');
|
|
436
|
-
if (this[
|
|
437
|
-
return inboundQ.consume(this[
|
|
436
|
+
if (this[kFlags].isParallelJoin) {
|
|
437
|
+
return inboundQ.consume(this[kMessageHandlers].onInbound, {consumerTag: '_run-on-inbound', prefetch: 1000});
|
|
438
438
|
}
|
|
439
439
|
|
|
440
|
-
return inboundQ.consume(this[
|
|
440
|
+
return inboundQ.consume(this[kMessageHandlers].onInbound, {consumerTag: '_run-on-inbound'});
|
|
441
441
|
};
|
|
442
442
|
|
|
443
443
|
proto._onInbound = function onInbound(routingKey, message) {
|
|
@@ -452,6 +452,7 @@ proto._onInbound = function onInbound(routingKey, message) {
|
|
|
452
452
|
switch (routingKey) {
|
|
453
453
|
case 'association.take':
|
|
454
454
|
case 'flow.take':
|
|
455
|
+
case 'activity.restart':
|
|
455
456
|
case 'activity.enter':
|
|
456
457
|
return this.run({
|
|
457
458
|
message: content.message,
|
|
@@ -478,7 +479,7 @@ proto._onInbound = function onInbound(routingKey, message) {
|
|
|
478
479
|
|
|
479
480
|
proto._onJoinInbound = function onJoinInbound(routingKey, message) {
|
|
480
481
|
const {content} = message;
|
|
481
|
-
const {inboundSequenceFlows, inboundJoinFlows, inboundTriggers} = this[
|
|
482
|
+
const {inboundSequenceFlows, inboundJoinFlows, inboundTriggers} = this[kFlows];
|
|
482
483
|
const idx = inboundJoinFlows.findIndex((msg) => msg.content.id === content.id);
|
|
483
484
|
|
|
484
485
|
inboundJoinFlows.push(message);
|
|
@@ -522,7 +523,7 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
|
522
523
|
switch (routingKey) {
|
|
523
524
|
case 'activity.enter':
|
|
524
525
|
case 'activity.discard': {
|
|
525
|
-
if (content.id === this[
|
|
526
|
+
if (content.id === this[kFlags].attachedTo) {
|
|
526
527
|
inboundQ.queueMessage(fields, cloneContent(content), properties);
|
|
527
528
|
}
|
|
528
529
|
break;
|
|
@@ -539,7 +540,7 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
|
539
540
|
return inboundQ.purge();
|
|
540
541
|
}
|
|
541
542
|
case 'association.complete': {
|
|
542
|
-
if (!this[
|
|
543
|
+
if (!this[kFlags].isForCompensation) break;
|
|
543
544
|
|
|
544
545
|
inboundQ.queueMessage(fields, cloneContent(content), properties);
|
|
545
546
|
|
|
@@ -557,10 +558,10 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
|
557
558
|
};
|
|
558
559
|
|
|
559
560
|
proto._consumeRunQ = function consumeRunQ() {
|
|
560
|
-
if (this[
|
|
561
|
+
if (this[kConsuming]) return;
|
|
561
562
|
|
|
562
|
-
this[
|
|
563
|
-
this.broker.getQueue('run-q').assertConsumer(this[
|
|
563
|
+
this[kConsuming] = true;
|
|
564
|
+
this.broker.getQueue('run-q').assertConsumer(this[kMessageHandlers].onRunMessage, {exclusive: true, consumerTag: '_activity-run'});
|
|
564
565
|
};
|
|
565
566
|
|
|
566
567
|
proto._onRunMessage = function onRunMessage(routingKey, message, messageProperties) {
|
|
@@ -591,7 +592,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
591
592
|
|
|
592
593
|
const id = this.id;
|
|
593
594
|
const step = this.environment.settings.step;
|
|
594
|
-
this[
|
|
595
|
+
this[kStateMessage] = message;
|
|
595
596
|
|
|
596
597
|
switch (routingKey) {
|
|
597
598
|
case 'run.enter': {
|
|
@@ -599,7 +600,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
599
600
|
|
|
600
601
|
this.status = 'entered';
|
|
601
602
|
if (!isRedelivered) {
|
|
602
|
-
this[
|
|
603
|
+
this[kExec].execution = null;
|
|
603
604
|
}
|
|
604
605
|
|
|
605
606
|
if (this.extensions) this.extensions.activate(cloneMessage(message), this);
|
|
@@ -612,7 +613,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
612
613
|
this.logger.debug(`<${id}> discard`, isRedelivered ? 'redelivered' : '');
|
|
613
614
|
|
|
614
615
|
this.status = 'discard';
|
|
615
|
-
this[
|
|
616
|
+
this[kExec].execution = null;
|
|
616
617
|
|
|
617
618
|
if (this.extensions) this.extensions.activate(cloneMessage(message), this);
|
|
618
619
|
if (this.bpmnIo) this.bpmnIo.activate(message);
|
|
@@ -636,16 +637,16 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
636
637
|
case 'run.execute.passthrough': {
|
|
637
638
|
const execution = this.execution;
|
|
638
639
|
if (!isRedelivered && execution) {
|
|
639
|
-
this[
|
|
640
|
+
this[kExecuteMessage] = message;
|
|
640
641
|
return execution.passthrough(message);
|
|
641
642
|
}
|
|
642
643
|
}
|
|
643
644
|
case 'run.execute': {
|
|
644
645
|
this.status = 'executing';
|
|
645
|
-
this[
|
|
646
|
+
this[kExecuteMessage] = message;
|
|
646
647
|
|
|
647
|
-
this.broker.getQueue('execution-q').assertConsumer(this[
|
|
648
|
-
const exec = this[
|
|
648
|
+
this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {exclusive: true, consumerTag: '_activity-execution'});
|
|
649
|
+
const exec = this[kExec];
|
|
649
650
|
if (!exec.execution) exec.execution = new ActivityExecution(this, this.context);
|
|
650
651
|
|
|
651
652
|
if (isRedelivered) {
|
|
@@ -662,12 +663,10 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
662
663
|
case 'run.end': {
|
|
663
664
|
if (this.status === 'end') break;
|
|
664
665
|
|
|
665
|
-
this[
|
|
666
|
+
this[kCounters].taken++;
|
|
666
667
|
|
|
667
668
|
this.status = 'end';
|
|
668
669
|
|
|
669
|
-
if (isRedelivered) break;
|
|
670
|
-
|
|
671
670
|
return this._doRunLeave(message, false, () => {
|
|
672
671
|
this._publishEvent('end', content, {correlationId});
|
|
673
672
|
if (!step) message.ack();
|
|
@@ -682,7 +681,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
682
681
|
}
|
|
683
682
|
case 'run.discarded': {
|
|
684
683
|
this.logger.debug(`<${content.executionId} (${id})> discarded`);
|
|
685
|
-
this[
|
|
684
|
+
this[kCounters].discarded++;
|
|
686
685
|
|
|
687
686
|
this.status = 'discarded';
|
|
688
687
|
content.outbound = undefined;
|
|
@@ -727,7 +726,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
727
726
|
};
|
|
728
727
|
|
|
729
728
|
proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
730
|
-
const executeMessage = this[
|
|
729
|
+
const executeMessage = this[kExecuteMessage];
|
|
731
730
|
const content = cloneContent({
|
|
732
731
|
...executeMessage.content,
|
|
733
732
|
...message.content,
|
|
@@ -771,8 +770,8 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
|
771
770
|
|
|
772
771
|
proto._ackRunExecuteMessage = function ackRunExecuteMessage() {
|
|
773
772
|
if (this.environment.settings.step) return;
|
|
774
|
-
const executeMessage = this[
|
|
775
|
-
this[
|
|
773
|
+
const executeMessage = this[kExecuteMessage];
|
|
774
|
+
this[kExecuteMessage] = null;
|
|
776
775
|
executeMessage.ack();
|
|
777
776
|
};
|
|
778
777
|
|
|
@@ -790,7 +789,7 @@ proto._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
|
|
|
790
789
|
}
|
|
791
790
|
|
|
792
791
|
this.broker.publish('run', 'run.leave', cloneContent(content, {
|
|
793
|
-
...(outbound.length
|
|
792
|
+
...(outbound.length && {outbound}),
|
|
794
793
|
}), {correlationId});
|
|
795
794
|
|
|
796
795
|
onOutbound();
|
|
@@ -798,13 +797,13 @@ proto._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
|
|
|
798
797
|
};
|
|
799
798
|
|
|
800
799
|
proto._doOutbound = function doOutbound(fromMessage, isDiscarded, callback) {
|
|
801
|
-
const outboundSequenceFlows = this[
|
|
800
|
+
const outboundSequenceFlows = this[kFlows].outboundSequenceFlows;
|
|
802
801
|
if (!outboundSequenceFlows.length) return callback(null, []);
|
|
803
802
|
|
|
804
803
|
const fromContent = fromMessage.content;
|
|
805
804
|
|
|
806
805
|
let discardSequence = fromContent.discardSequence;
|
|
807
|
-
if (isDiscarded && !discardSequence && this[
|
|
806
|
+
if (isDiscarded && !discardSequence && this[kFlags].attachedTo && fromContent.inbound && fromContent.inbound[0]) {
|
|
808
807
|
discardSequence = [fromContent.inbound[0].id];
|
|
809
808
|
}
|
|
810
809
|
|
|
@@ -834,7 +833,7 @@ proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequ
|
|
|
834
833
|
flow: {
|
|
835
834
|
...outboundFlow,
|
|
836
835
|
sequenceId: getUniqueId(`${flowId}_${action}`),
|
|
837
|
-
...(discardSequence
|
|
836
|
+
...(discardSequence && {discardSequence: discardSequence.slice()}),
|
|
838
837
|
},
|
|
839
838
|
}));
|
|
840
839
|
}
|
|
@@ -844,7 +843,7 @@ proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequ
|
|
|
844
843
|
proto._onResumeMessage = function onResumeMessage(message) {
|
|
845
844
|
message.ack();
|
|
846
845
|
|
|
847
|
-
const stateMessage = this[
|
|
846
|
+
const stateMessage = this[kStateMessage];
|
|
848
847
|
const {fields} = stateMessage;
|
|
849
848
|
|
|
850
849
|
switch (fields.routingKey) {
|
|
@@ -875,11 +874,11 @@ proto._publishEvent = function publishEvent(state, content, properties = {}) {
|
|
|
875
874
|
};
|
|
876
875
|
|
|
877
876
|
proto._onStop = function onStop(message) {
|
|
878
|
-
const running = this[
|
|
877
|
+
const running = this[kConsuming];
|
|
879
878
|
|
|
880
879
|
this.stopped = true;
|
|
881
880
|
|
|
882
|
-
this[
|
|
881
|
+
this[kConsuming] = false;
|
|
883
882
|
const broker = this.broker;
|
|
884
883
|
broker.cancel('_activity-run');
|
|
885
884
|
broker.cancel('_activity-api');
|
|
@@ -894,11 +893,11 @@ proto._onStop = function onStop(message) {
|
|
|
894
893
|
};
|
|
895
894
|
|
|
896
895
|
proto._consumeApi = function consumeApi() {
|
|
897
|
-
const executionId = this[
|
|
896
|
+
const executionId = this[kExec].executionId;
|
|
898
897
|
if (!executionId) return;
|
|
899
898
|
const broker = this.broker;
|
|
900
899
|
broker.cancel('_activity-api');
|
|
901
|
-
broker.subscribeTmp('api', `activity.*.${executionId}`, this[
|
|
900
|
+
broker.subscribeTmp('api', `activity.*.${executionId}`, this[kMessageHandlers].onApiMessage, {noAck: true, consumerTag: '_activity-api', priority: 100});
|
|
902
901
|
};
|
|
903
902
|
|
|
904
903
|
proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
@@ -921,12 +920,12 @@ proto._createMessage = function createMessage(override) {
|
|
|
921
920
|
...override,
|
|
922
921
|
id: this.id,
|
|
923
922
|
type: this.type,
|
|
924
|
-
...(name
|
|
925
|
-
...(status
|
|
926
|
-
...(parent
|
|
923
|
+
...(name && {name}),
|
|
924
|
+
...(status && {status}),
|
|
925
|
+
...(parent && {parent: cloneParent(parent)}),
|
|
927
926
|
};
|
|
928
927
|
|
|
929
|
-
for (const [flag, value] of Object.entries(this[
|
|
928
|
+
for (const [flag, value] of Object.entries(this[kFlags])) {
|
|
930
929
|
if (value) result[flag] = value;
|
|
931
930
|
}
|
|
932
931
|
|
|
@@ -934,7 +933,7 @@ proto._createMessage = function createMessage(override) {
|
|
|
934
933
|
};
|
|
935
934
|
|
|
936
935
|
proto._getOutboundSequenceFlowById = function getOutboundSequenceFlowById(flowId) {
|
|
937
|
-
return this[
|
|
936
|
+
return this[kFlows].outboundSequenceFlows.find((flow) => flow.id === flowId);
|
|
938
937
|
};
|
|
939
938
|
|
|
940
939
|
proto._resumeExtensions = function resumeExtensions(message, callback) {
|
|
@@ -956,7 +955,7 @@ proto._deactivateRunConsumers = function _deactivateRunConsumers() {
|
|
|
956
955
|
broker.cancel('_activity-api');
|
|
957
956
|
broker.cancel('_activity-run');
|
|
958
957
|
broker.cancel('_activity-execution');
|
|
959
|
-
this[
|
|
958
|
+
this[kConsuming] = false;
|
|
960
959
|
};
|
|
961
960
|
|
|
962
961
|
function OutboundEvaluator(activity, outboundFlows) {
|
|
@@ -1072,7 +1071,7 @@ OutboundEvaluator.prototype.completed = function completed(err) {
|
|
|
1072
1071
|
for (const flow of Object.values(result)) {
|
|
1073
1072
|
evaluationResult.push({
|
|
1074
1073
|
...flow,
|
|
1075
|
-
...(message !== undefined
|
|
1074
|
+
...(message !== undefined && {message}),
|
|
1076
1075
|
});
|
|
1077
1076
|
}
|
|
1078
1077
|
|
|
@@ -1084,6 +1083,6 @@ function formatFlowAction(flow, options) {
|
|
|
1084
1083
|
...options,
|
|
1085
1084
|
id: flow.id,
|
|
1086
1085
|
action: options.action,
|
|
1087
|
-
...(flow.isDefault
|
|
1086
|
+
...(flow.isDefault && {isDefault: true}),
|
|
1088
1087
|
};
|
|
1089
1088
|
}
|