bpmn-elements 14.1.0 → 15.0.1
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/README.md +0 -4
- package/dist/Context.js +41 -35
- package/dist/Environment.js +4 -4
- package/dist/Expressions.js +1 -1
- package/dist/MessageFormatter.js +0 -1
- package/dist/Scripts.js +3 -8
- package/dist/Timers.js +5 -9
- package/dist/Tracker.js +15 -19
- package/dist/activity/Activity.js +68 -49
- package/dist/activity/ActivityExecution.js +43 -29
- package/dist/definition/Definition.js +20 -14
- package/dist/definition/DefinitionExecution.js +64 -55
- package/dist/eventDefinitions/EscalationEventDefinition.js +1 -1
- package/dist/eventDefinitions/LinkEventDefinition.js +1 -1
- package/dist/eventDefinitions/MessageEventDefinition.js +1 -1
- package/dist/eventDefinitions/SignalEventDefinition.js +1 -1
- package/dist/eventDefinitions/TimerEventDefinition.js +1 -1
- package/dist/events/BoundaryEvent.js +11 -9
- package/dist/events/EndEvent.js +1 -1
- package/dist/events/IntermediateCatchEvent.js +1 -1
- package/dist/events/IntermediateThrowEvent.js +1 -1
- package/dist/events/StartEvent.js +1 -1
- package/dist/flows/SequenceFlow.js +1 -1
- package/dist/gateways/EventBasedGateway.js +1 -1
- package/dist/gateways/ExclusiveGateway.js +1 -1
- package/dist/gateways/InclusiveGateway.js +1 -1
- package/dist/gateways/ParallelGateway.js +1 -1
- package/dist/index.js +1 -1
- package/dist/io/InputOutputSpecification.js +1 -1
- package/dist/io/Properties.js +1 -1
- package/dist/process/Process.js +20 -19
- package/dist/process/ProcessExecution.js +67 -40
- package/dist/shared.js +0 -8
- package/dist/tasks/CallActivity.js +1 -1
- package/dist/tasks/LoopCharacteristics.js +2 -2
- package/dist/tasks/ReceiveTask.js +1 -1
- package/dist/tasks/ScriptTask.js +3 -3
- package/dist/tasks/ServiceImplementation.js +1 -1
- package/dist/tasks/ServiceTask.js +1 -1
- package/dist/tasks/SignalTask.js +1 -1
- package/dist/tasks/StandardLoopCharacteristics.js +1 -1
- package/dist/tasks/SubProcess.js +30 -33
- package/dist/tasks/Task.js +1 -1
- package/dist/tasks/Transaction.js +1 -1
- package/package.json +4 -4
- package/src/Context.js +51 -35
- package/src/Environment.js +4 -4
- package/src/MessageFormatter.js +0 -3
- package/src/Scripts.js +3 -8
- package/src/Timers.js +5 -9
- package/src/Tracker.js +13 -17
- package/src/activity/Activity.js +57 -42
- package/src/activity/ActivityExecution.js +43 -26
- package/src/definition/Definition.js +19 -13
- package/src/definition/DefinitionExecution.js +64 -54
- package/src/eventDefinitions/TimerEventDefinition.js +1 -1
- package/src/events/BoundaryEvent.js +10 -8
- package/src/process/Process.js +20 -15
- package/src/process/ProcessExecution.js +70 -40
- package/src/shared.js +0 -8
- package/src/tasks/LoopCharacteristics.js +2 -2
- package/src/tasks/ScriptTask.js +2 -2
- package/src/tasks/SubProcess.js +31 -32
- package/types/types.d.ts +1 -1
|
@@ -24,21 +24,21 @@ export default function DefinitionExecution(definition, context) {
|
|
|
24
24
|
this.context = context;
|
|
25
25
|
|
|
26
26
|
const processes = context.getProcesses();
|
|
27
|
-
const ids =
|
|
28
|
-
const executable =
|
|
27
|
+
const ids = new Set();
|
|
28
|
+
const executable = new Set();
|
|
29
29
|
for (const bp of processes) {
|
|
30
30
|
bp.environment.assignVariables(environment.variables);
|
|
31
31
|
bp.environment.assignSettings(environment.settings);
|
|
32
|
-
ids.
|
|
33
|
-
if (bp.isExecutable) executable.
|
|
32
|
+
ids.add(bp.id);
|
|
33
|
+
if (bp.isExecutable) executable.add(bp);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
this[kProcesses] = {
|
|
37
37
|
processes,
|
|
38
|
-
running: [],
|
|
39
38
|
ids,
|
|
40
39
|
executable,
|
|
41
|
-
|
|
40
|
+
running: new Set(),
|
|
41
|
+
postponed: new Set(),
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
broker.assertExchange('execution', 'topic', { autoDelete: false, durable: true });
|
|
@@ -79,12 +79,12 @@ Object.defineProperties(DefinitionExecution.prototype, {
|
|
|
79
79
|
},
|
|
80
80
|
processes: {
|
|
81
81
|
get() {
|
|
82
|
-
return this[kProcesses].running;
|
|
82
|
+
return [...this[kProcesses].running];
|
|
83
83
|
},
|
|
84
84
|
},
|
|
85
85
|
postponedCount: {
|
|
86
86
|
get() {
|
|
87
|
-
return this[kProcesses].postponed.
|
|
87
|
+
return this[kProcesses].postponed.size;
|
|
88
88
|
},
|
|
89
89
|
},
|
|
90
90
|
isRunning: {
|
|
@@ -96,7 +96,7 @@ Object.defineProperties(DefinitionExecution.prototype, {
|
|
|
96
96
|
get() {
|
|
97
97
|
let status = 'idle';
|
|
98
98
|
const running = this[kProcesses].running;
|
|
99
|
-
if (!running
|
|
99
|
+
if (!running.size) return status;
|
|
100
100
|
|
|
101
101
|
for (const bp of running) {
|
|
102
102
|
const bpStatus = bp.activityStatus;
|
|
@@ -143,13 +143,15 @@ DefinitionExecution.prototype.execute = function execute(executeMessage) {
|
|
|
143
143
|
if (content.processId) {
|
|
144
144
|
const startWithProcess = this.getProcessById(content.processId);
|
|
145
145
|
if (startWithProcess) {
|
|
146
|
-
executable.
|
|
147
|
-
executable.
|
|
146
|
+
executable.clear();
|
|
147
|
+
executable.add(startWithProcess);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
this._debug('execute definition');
|
|
152
|
-
|
|
152
|
+
for (const bp of executable) {
|
|
153
|
+
running.add(bp);
|
|
154
|
+
}
|
|
153
155
|
this._activate(executable);
|
|
154
156
|
this._start();
|
|
155
157
|
return true;
|
|
@@ -162,7 +164,7 @@ DefinitionExecution.prototype.resume = function resume() {
|
|
|
162
164
|
|
|
163
165
|
const { running, postponed } = this[kProcesses];
|
|
164
166
|
this._activate(running);
|
|
165
|
-
postponed.
|
|
167
|
+
postponed.clear();
|
|
166
168
|
this[kProcessesQ].consume(this[kMessageHandlers].onProcessMessage, {
|
|
167
169
|
prefetch: 1000,
|
|
168
170
|
consumerTag: `_definition-activity-${this.executionId}`,
|
|
@@ -184,22 +186,22 @@ DefinitionExecution.prototype.recover = function recover(state) {
|
|
|
184
186
|
this._debug(`recover ${this[kStatus]} definition execution`);
|
|
185
187
|
|
|
186
188
|
const running = this[kProcesses].running;
|
|
187
|
-
running.
|
|
189
|
+
running.clear();
|
|
188
190
|
|
|
189
|
-
const ids =
|
|
191
|
+
const ids = new Set();
|
|
190
192
|
for (const bpState of state.processes) {
|
|
191
193
|
const bpid = bpState.id;
|
|
192
194
|
let bp;
|
|
193
|
-
if (ids.
|
|
195
|
+
if (ids.has(bpid)) {
|
|
194
196
|
bp = this.context.getNewProcessById(bpid);
|
|
195
197
|
} else {
|
|
196
198
|
bp = this.getProcessById(bpid);
|
|
197
199
|
}
|
|
198
200
|
if (!bp) continue;
|
|
199
201
|
|
|
200
|
-
ids.
|
|
202
|
+
ids.add(bpid);
|
|
201
203
|
bp.recover(bpState);
|
|
202
|
-
running.
|
|
204
|
+
running.add(bp);
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
return this;
|
|
@@ -211,7 +213,7 @@ DefinitionExecution.prototype.stop = function stop() {
|
|
|
211
213
|
|
|
212
214
|
DefinitionExecution.prototype.getProcesses = function getProcesses() {
|
|
213
215
|
const { running, processes } = this[kProcesses];
|
|
214
|
-
const result = running
|
|
216
|
+
const result = [...running];
|
|
215
217
|
for (const bp of processes) {
|
|
216
218
|
if (!result.find((runningBp) => bp.id === runningBp.id)) result.push(bp);
|
|
217
219
|
}
|
|
@@ -227,26 +229,31 @@ DefinitionExecution.prototype.getProcessesById = function getProcessesById(proce
|
|
|
227
229
|
};
|
|
228
230
|
|
|
229
231
|
DefinitionExecution.prototype.getProcessByExecutionId = function getProcessByExecutionId(processExecutionId) {
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
+
for (const bp of this[kProcesses].running) {
|
|
233
|
+
if (bp.executionId === processExecutionId) return bp;
|
|
234
|
+
}
|
|
232
235
|
};
|
|
233
236
|
|
|
234
237
|
DefinitionExecution.prototype.getRunningProcesses = function getRunningProcesses() {
|
|
235
|
-
|
|
236
|
-
return running.filter((bp) => bp.executionId);
|
|
238
|
+
return [...this[kProcesses].running].filter((bp) => bp.executionId);
|
|
237
239
|
};
|
|
238
240
|
|
|
239
241
|
DefinitionExecution.prototype.getExecutableProcesses = function getExecutableProcesses() {
|
|
240
|
-
return this[kProcesses].executable
|
|
242
|
+
return [...this[kProcesses].executable];
|
|
241
243
|
};
|
|
242
244
|
|
|
243
245
|
DefinitionExecution.prototype.getState = function getState() {
|
|
246
|
+
const processes = [];
|
|
247
|
+
for (const bp of this[kProcesses].running) {
|
|
248
|
+
processes.push(bp.getState());
|
|
249
|
+
}
|
|
250
|
+
|
|
244
251
|
return {
|
|
245
252
|
executionId: this.executionId,
|
|
246
253
|
stopped: this[kStopped],
|
|
247
254
|
completed: this[kCompleted],
|
|
248
255
|
status: this[kStatus],
|
|
249
|
-
processes
|
|
256
|
+
processes,
|
|
250
257
|
};
|
|
251
258
|
};
|
|
252
259
|
|
|
@@ -263,31 +270,32 @@ DefinitionExecution.prototype.getApi = function getApi(apiMessage) {
|
|
|
263
270
|
const self = this;
|
|
264
271
|
|
|
265
272
|
api.getExecuting = function getExecuting() {
|
|
266
|
-
|
|
273
|
+
const apis = [];
|
|
274
|
+
for (const msg of postponed) {
|
|
267
275
|
const bpApi = self._getProcessApi(msg);
|
|
268
|
-
if (bpApi)
|
|
269
|
-
|
|
270
|
-
|
|
276
|
+
if (bpApi) apis.push(bpApi);
|
|
277
|
+
}
|
|
278
|
+
return apis;
|
|
271
279
|
};
|
|
272
280
|
|
|
273
281
|
return api;
|
|
274
282
|
};
|
|
275
283
|
|
|
276
284
|
DefinitionExecution.prototype.getPostponed = function getPostponed(...args) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
result = result.concat(
|
|
280
|
-
|
|
281
|
-
|
|
285
|
+
let result = [];
|
|
286
|
+
for (const bp of this[kProcesses].running) {
|
|
287
|
+
result = result.concat(bp.getPostponed(...args));
|
|
288
|
+
}
|
|
289
|
+
return result;
|
|
282
290
|
};
|
|
283
291
|
|
|
284
292
|
DefinitionExecution.prototype._start = function start() {
|
|
285
293
|
const { ids, executable, postponed } = this[kProcesses];
|
|
286
|
-
if (!ids.
|
|
294
|
+
if (!ids.size) {
|
|
287
295
|
return this._complete('completed');
|
|
288
296
|
}
|
|
289
297
|
|
|
290
|
-
if (!executable.
|
|
298
|
+
if (!executable.size) {
|
|
291
299
|
return this._complete('error', { error: new Error('No executable process') });
|
|
292
300
|
}
|
|
293
301
|
|
|
@@ -296,7 +304,7 @@ DefinitionExecution.prototype._start = function start() {
|
|
|
296
304
|
for (const bp of executable) bp.init();
|
|
297
305
|
for (const bp of executable) bp.run();
|
|
298
306
|
|
|
299
|
-
postponed.
|
|
307
|
+
postponed.clear();
|
|
300
308
|
this[kProcessesQ].assertConsumer(this[kMessageHandlers].onProcessMessage, {
|
|
301
309
|
prefetch: 1000,
|
|
302
310
|
consumerTag: `_definition-activity-${this.executionId}`,
|
|
@@ -348,7 +356,7 @@ DefinitionExecution.prototype._onChildEvent = function onChildEvent(routingKey,
|
|
|
348
356
|
const content = message.content;
|
|
349
357
|
const parent = (content.parent = content.parent || {});
|
|
350
358
|
|
|
351
|
-
const isDirectChild = this[kProcesses].ids.
|
|
359
|
+
const isDirectChild = this[kProcesses].ids.has(content.id);
|
|
352
360
|
if (isDirectChild) {
|
|
353
361
|
parent.executionId = this.executionId;
|
|
354
362
|
} else {
|
|
@@ -434,7 +442,7 @@ DefinitionExecution.prototype._onProcessMessage = function onProcessMessage(rout
|
|
|
434
442
|
{ mandatory: true, type: 'error' },
|
|
435
443
|
);
|
|
436
444
|
} else {
|
|
437
|
-
for (const bp of this[kProcesses].running
|
|
445
|
+
for (const bp of new Set(this[kProcesses].running)) {
|
|
438
446
|
if (bp.id !== childId) bp.stop();
|
|
439
447
|
}
|
|
440
448
|
|
|
@@ -450,13 +458,16 @@ DefinitionExecution.prototype._onProcessMessage = function onProcessMessage(rout
|
|
|
450
458
|
DefinitionExecution.prototype._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
|
|
451
459
|
let previousMsg;
|
|
452
460
|
const postponed = this[kProcesses].postponed;
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
461
|
+
for (const msg of postponed) {
|
|
462
|
+
if (msg.content.executionId === message.content.executionId) {
|
|
463
|
+
previousMsg = msg;
|
|
464
|
+
postponed.delete(msg);
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
456
467
|
}
|
|
457
468
|
|
|
458
469
|
if (previousMsg) previousMsg.ack();
|
|
459
|
-
if (postponeMessage) postponed.
|
|
470
|
+
if (postponeMessage) postponed.add(message);
|
|
460
471
|
};
|
|
461
472
|
|
|
462
473
|
DefinitionExecution.prototype._onProcessCompleted = function onProcessCompleted(message) {
|
|
@@ -479,9 +490,9 @@ DefinitionExecution.prototype._onProcessCompleted = function onProcessCompleted(
|
|
|
479
490
|
|
|
480
491
|
DefinitionExecution.prototype._onStopped = function onStopped(message) {
|
|
481
492
|
const running = this[kProcesses].running;
|
|
482
|
-
this._debug(`stop definition execution (stop process executions ${running.
|
|
493
|
+
this._debug(`stop definition execution (stop process executions ${running.size})`);
|
|
483
494
|
this[kProcessesQ].close();
|
|
484
|
-
for (const bp of running
|
|
495
|
+
for (const bp of new Set(running)) bp.stop();
|
|
485
496
|
this._deactivate();
|
|
486
497
|
|
|
487
498
|
this[kStopped] = true;
|
|
@@ -505,7 +516,7 @@ DefinitionExecution.prototype._onApiMessage = function onApiMessage(routingKey,
|
|
|
505
516
|
}
|
|
506
517
|
|
|
507
518
|
if (delegate) {
|
|
508
|
-
for (const bp of this[kProcesses].running
|
|
519
|
+
for (const bp of new Set(this[kProcesses].running)) {
|
|
509
520
|
bp.broker.publish('api', routingKey, cloneContent(message.content), message.properties);
|
|
510
521
|
}
|
|
511
522
|
}
|
|
@@ -528,7 +539,7 @@ DefinitionExecution.prototype._startProcessesByMessage = function startProcesses
|
|
|
528
539
|
if (!bp.executionId) {
|
|
529
540
|
this._debug(`start <${bp.id}> by <${reference.referenceId}> (${reference.referenceType})`);
|
|
530
541
|
this._activateProcess(bp);
|
|
531
|
-
running.
|
|
542
|
+
running.add(bp);
|
|
532
543
|
bp.init();
|
|
533
544
|
bp.run();
|
|
534
545
|
if (reference.referenceType === 'message') return;
|
|
@@ -539,7 +550,7 @@ DefinitionExecution.prototype._startProcessesByMessage = function startProcesses
|
|
|
539
550
|
|
|
540
551
|
const targetProcess = this.context.getNewProcessById(bp.id);
|
|
541
552
|
this._activateProcess(targetProcess);
|
|
542
|
-
running.
|
|
553
|
+
running.add(targetProcess);
|
|
543
554
|
targetProcess.init();
|
|
544
555
|
targetProcess.run();
|
|
545
556
|
if (reference.referenceType === 'message') return;
|
|
@@ -573,7 +584,7 @@ DefinitionExecution.prototype._onMessageOutbound = function onMessageOutbound(ro
|
|
|
573
584
|
targetProcess = targetProcess || this.context.getNewProcessById(target.processId);
|
|
574
585
|
|
|
575
586
|
this._activateProcess(targetProcess);
|
|
576
|
-
this[kProcesses].running.
|
|
587
|
+
this[kProcesses].running.add(targetProcess);
|
|
577
588
|
targetProcess.init();
|
|
578
589
|
targetProcess.run();
|
|
579
590
|
targetProcess.sendMessage(message);
|
|
@@ -605,7 +616,7 @@ DefinitionExecution.prototype._onCallActivity = function onCallActivity(routingK
|
|
|
605
616
|
this._debug(`call from <${fromParent.id}.${fromId}> to <${calledElement}>`);
|
|
606
617
|
|
|
607
618
|
this._activateProcess(targetProcess);
|
|
608
|
-
this[kProcesses].running.
|
|
619
|
+
this[kProcesses].running.add(targetProcess);
|
|
609
620
|
targetProcess.init(bpExecutionId);
|
|
610
621
|
targetProcess.run({ inbound: [cloneContent(content)] });
|
|
611
622
|
};
|
|
@@ -672,10 +683,9 @@ DefinitionExecution.prototype._onDelegateMessage = function onDelegateMessage(ro
|
|
|
672
683
|
};
|
|
673
684
|
|
|
674
685
|
DefinitionExecution.prototype._removeProcessByExecutionId = function removeProcessByExecutionId(processExecutionId) {
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
return running.splice(idx, 1)[0];
|
|
686
|
+
const bp = this.getProcessByExecutionId(processExecutionId);
|
|
687
|
+
if (bp) this[kProcesses].running.delete(bp);
|
|
688
|
+
return bp;
|
|
679
689
|
};
|
|
680
690
|
|
|
681
691
|
DefinitionExecution.prototype._complete = function complete(completionType, content, options) {
|
|
@@ -6,7 +6,7 @@ const kStopped = Symbol.for('stopped');
|
|
|
6
6
|
const kTimerContent = Symbol.for('timerContent');
|
|
7
7
|
const kTimer = Symbol.for('timer');
|
|
8
8
|
|
|
9
|
-
const timerTypes = ['timeDuration', 'timeDate', 'timeCycle'];
|
|
9
|
+
const timerTypes = new Set(['timeDuration', 'timeDate', 'timeCycle']);
|
|
10
10
|
|
|
11
11
|
export default function TimerEventDefinition(activity, eventDefinition) {
|
|
12
12
|
const type = (this.type = eventDefinition.type || 'TimerEventDefinition');
|
|
@@ -22,8 +22,8 @@ export function BoundaryEventBehaviour(activity) {
|
|
|
22
22
|
this.broker = activity.broker;
|
|
23
23
|
this[kExecution] =
|
|
24
24
|
activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions, 'execute.bound.completed');
|
|
25
|
-
this[kShovels] =
|
|
26
|
-
this[kAttachedTags] =
|
|
25
|
+
this[kShovels] = new Set();
|
|
26
|
+
this[kAttachedTags] = new Set();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
Object.defineProperties(BoundaryEventBehaviour.prototype, {
|
|
@@ -60,7 +60,7 @@ BoundaryEventBehaviour.prototype.execute = function execute(executeMessage) {
|
|
|
60
60
|
consumerTag,
|
|
61
61
|
priority: 300,
|
|
62
62
|
});
|
|
63
|
-
this[kAttachedTags].
|
|
63
|
+
this[kAttachedTags].add(consumerTag);
|
|
64
64
|
|
|
65
65
|
broker.subscribeOnce('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
|
|
66
66
|
consumerTag: `_api-${executionId}`,
|
|
@@ -118,7 +118,7 @@ BoundaryEventBehaviour.prototype._onCompleted = function onCompleted(_, { conten
|
|
|
118
118
|
|
|
119
119
|
if (content.isRecovered && !attachedTo.isRunning) {
|
|
120
120
|
const attachedExecuteTag = `_on-attached-execute-${executionId}`;
|
|
121
|
-
this[kAttachedTags].
|
|
121
|
+
this[kAttachedTags].add(attachedExecuteTag);
|
|
122
122
|
attachedTo.broker.subscribeOnce(
|
|
123
123
|
'execution',
|
|
124
124
|
'#',
|
|
@@ -146,7 +146,7 @@ BoundaryEventBehaviour.prototype._onExpectMessage = function onExpectMessage(_,
|
|
|
146
146
|
const attachedTo = this.attachedTo;
|
|
147
147
|
|
|
148
148
|
const errorConsumerTag = `_bound-error-listener-${executionId}`;
|
|
149
|
-
this[kAttachedTags].
|
|
149
|
+
this[kAttachedTags].add(errorConsumerTag);
|
|
150
150
|
|
|
151
151
|
attachedTo.broker.subscribeTmp(
|
|
152
152
|
'event',
|
|
@@ -177,7 +177,7 @@ BoundaryEventBehaviour.prototype._onDetachMessage = function onDetachMessage(_,
|
|
|
177
177
|
const { executionId: detachId, bindExchange, sourceExchange, sourcePattern } = content;
|
|
178
178
|
|
|
179
179
|
const shovelName = `_detached-${brokerSafeId(id)}_${detachId}`;
|
|
180
|
-
this[kShovels].
|
|
180
|
+
this[kShovels].add(shovelName);
|
|
181
181
|
|
|
182
182
|
const broker = this.broker;
|
|
183
183
|
attachedTo.broker.createShovel(
|
|
@@ -238,8 +238,10 @@ BoundaryEventBehaviour.prototype._stop = function stop(detach) {
|
|
|
238
238
|
const attachedTo = this.attachedTo,
|
|
239
239
|
broker = this.broker,
|
|
240
240
|
executionId = this.executionId;
|
|
241
|
-
for (const tag of this[kAttachedTags]
|
|
242
|
-
|
|
241
|
+
for (const tag of this[kAttachedTags]) attachedTo.broker.cancel(tag);
|
|
242
|
+
this[kAttachedTags].clear();
|
|
243
|
+
for (const shovelName of this[kShovels]) attachedTo.broker.closeShovel(shovelName);
|
|
244
|
+
this[kShovels].clear();
|
|
243
245
|
|
|
244
246
|
broker.cancel('_execution-tag');
|
|
245
247
|
broker.cancel(`_execution-completed-${executionId}`);
|
package/src/process/Process.js
CHANGED
|
@@ -36,7 +36,7 @@ export function Process(processDef, context) {
|
|
|
36
36
|
discarded: 0,
|
|
37
37
|
};
|
|
38
38
|
this[kConsuming] = false;
|
|
39
|
-
this[kExec] =
|
|
39
|
+
this[kExec] = new Map();
|
|
40
40
|
this[kStatus] = undefined;
|
|
41
41
|
this[kStopped] = false;
|
|
42
42
|
|
|
@@ -90,13 +90,13 @@ Object.defineProperties(Process.prototype, {
|
|
|
90
90
|
},
|
|
91
91
|
executionId: {
|
|
92
92
|
get() {
|
|
93
|
-
const
|
|
94
|
-
return executionId || initExecutionId;
|
|
93
|
+
const exec = this[kExec];
|
|
94
|
+
return exec.get('executionId') || exec.get('initExecutionId');
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
97
|
execution: {
|
|
98
98
|
get() {
|
|
99
|
-
return this[kExec].execution;
|
|
99
|
+
return this[kExec].get('execution');
|
|
100
100
|
},
|
|
101
101
|
},
|
|
102
102
|
status: {
|
|
@@ -106,14 +106,16 @@ Object.defineProperties(Process.prototype, {
|
|
|
106
106
|
},
|
|
107
107
|
activityStatus: {
|
|
108
108
|
get() {
|
|
109
|
-
|
|
109
|
+
const execution = this[kExec].get('execution');
|
|
110
|
+
return (execution && execution.activityStatus) || 'idle';
|
|
110
111
|
},
|
|
111
112
|
},
|
|
112
113
|
});
|
|
113
114
|
|
|
114
115
|
Process.prototype.init = function init(useAsExecutionId) {
|
|
115
|
-
const
|
|
116
|
-
|
|
116
|
+
const initExecutionId = useAsExecutionId || getUniqueId(this.id);
|
|
117
|
+
this[kExec].set('initExecutionId', initExecutionId);
|
|
118
|
+
|
|
117
119
|
this._debug(`initialized with executionId <${initExecutionId}>`);
|
|
118
120
|
this._publishEvent('init', this._createMessage({ executionId: initExecutionId }));
|
|
119
121
|
};
|
|
@@ -122,8 +124,9 @@ Process.prototype.run = function run(runContent) {
|
|
|
122
124
|
if (this.isRunning) throw new Error(`process <${this.id}> is already running`);
|
|
123
125
|
|
|
124
126
|
const exec = this[kExec];
|
|
125
|
-
const executionId =
|
|
126
|
-
exec.initExecutionId
|
|
127
|
+
const executionId = exec.get('initExecutionId') || getUniqueId(this.id);
|
|
128
|
+
exec.delete('initExecutionId');
|
|
129
|
+
exec.set('executionId', executionId);
|
|
127
130
|
|
|
128
131
|
const content = this._createMessage({ ...runContent, executionId });
|
|
129
132
|
|
|
@@ -168,12 +171,12 @@ Process.prototype.recover = function recover(state) {
|
|
|
168
171
|
this[kStopped] = !!state.stopped;
|
|
169
172
|
this[kStatus] = state.status;
|
|
170
173
|
const exec = this[kExec];
|
|
171
|
-
exec.executionId
|
|
174
|
+
exec.set('executionId', state.executionId);
|
|
172
175
|
this[kCounters] = { ...this[kCounters], ...state.counters };
|
|
173
176
|
this.environment.recover(state.environment);
|
|
174
177
|
|
|
175
178
|
if (state.execution) {
|
|
176
|
-
exec.execution
|
|
179
|
+
exec.set('execution', new ProcessExecution(this, this.context).recover(state.execution));
|
|
177
180
|
}
|
|
178
181
|
|
|
179
182
|
this.broker.recover(state.broker);
|
|
@@ -228,7 +231,6 @@ Process.prototype._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
228
231
|
return this._onResumeMessage(message);
|
|
229
232
|
}
|
|
230
233
|
|
|
231
|
-
const exec = this[kExec];
|
|
232
234
|
this[kStateMessage] = message;
|
|
233
235
|
|
|
234
236
|
switch (routingKey) {
|
|
@@ -238,7 +240,7 @@ Process.prototype._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
238
240
|
this[kStatus] = 'entered';
|
|
239
241
|
if (fields.redelivered) break;
|
|
240
242
|
|
|
241
|
-
|
|
243
|
+
this[kExec].delete('execution');
|
|
242
244
|
this._publishEvent('enter', content);
|
|
243
245
|
|
|
244
246
|
break;
|
|
@@ -250,9 +252,11 @@ Process.prototype._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
250
252
|
break;
|
|
251
253
|
}
|
|
252
254
|
case 'run.execute': {
|
|
255
|
+
const exec = this[kExec];
|
|
253
256
|
this[kStatus] = 'executing';
|
|
254
257
|
const executeMessage = cloneMessage(message);
|
|
255
|
-
|
|
258
|
+
let execution = exec.get('execution');
|
|
259
|
+
if (fields.redelivered && !execution) {
|
|
256
260
|
executeMessage.fields.redelivered = undefined;
|
|
257
261
|
}
|
|
258
262
|
this[kExecuteMessage] = message;
|
|
@@ -262,7 +266,8 @@ Process.prototype._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
262
266
|
consumerTag: '_process-execution',
|
|
263
267
|
});
|
|
264
268
|
|
|
265
|
-
|
|
269
|
+
execution = execution || new ProcessExecution(this, this.context);
|
|
270
|
+
exec.set('execution', execution);
|
|
266
271
|
return execution.execute(executeMessage);
|
|
267
272
|
}
|
|
268
273
|
case 'run.error': {
|