bpmn-elements 8.2.4 → 9.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 +16 -0
- package/README.md +1 -1
- package/dist/{src/Api.js → Api.js} +11 -12
- package/dist/{src/Context.js → Context.js} +26 -27
- package/dist/{src/Environment.js → Environment.js} +15 -16
- package/dist/{src/EventBroker.js → EventBroker.js} +5 -1
- package/dist/{src/Expressions.js → Expressions.js} +1 -1
- package/dist/{src/MessageFormatter.js → MessageFormatter.js} +3 -3
- package/dist/Tracker.js +89 -0
- package/dist/{src/activity → activity}/Activity.js +109 -120
- package/dist/{src/activity → activity}/ActivityExecution.js +28 -32
- package/dist/{src/activity → activity}/Dummy.js +1 -1
- package/dist/{src/activity → activity}/ExecutionScope.js +2 -2
- package/dist/{src/definition → definition}/Definition.js +64 -59
- package/dist/{src/definition → definition}/DefinitionExecution.js +68 -46
- package/dist/{src/error → error}/Errors.js +1 -1
- package/dist/eventDefinitions/CancelEventDefinition.js +127 -0
- package/dist/{src/eventDefinitions → eventDefinitions}/CompensateEventDefinition.js +64 -52
- package/dist/{src/eventDefinitions → eventDefinitions}/ConditionalEventDefinition.js +24 -16
- package/dist/{src/eventDefinitions → eventDefinitions}/ErrorEventDefinition.js +15 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/EscalationEventDefinition.js +12 -13
- package/dist/{src/eventDefinitions → eventDefinitions}/EventDefinitionExecution.js +10 -11
- package/dist/{src/eventDefinitions → eventDefinitions}/LinkEventDefinition.js +14 -15
- package/dist/{src/eventDefinitions → eventDefinitions}/MessageEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/SignalEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/TerminateEventDefinition.js +1 -1
- package/dist/{src/eventDefinitions → eventDefinitions}/TimerEventDefinition.js +15 -16
- package/dist/{src/events → events}/BoundaryEvent.js +39 -25
- package/dist/{src/events → events}/EndEvent.js +3 -3
- package/dist/{src/events → events}/IntermediateCatchEvent.js +3 -3
- package/dist/{src/events → events}/IntermediateThrowEvent.js +3 -3
- package/dist/{src/events → events}/StartEvent.js +8 -9
- package/dist/{src/flows → flows}/Association.js +14 -22
- package/dist/{src/flows → flows}/MessageFlow.js +16 -14
- package/dist/{src/flows → flows}/SequenceFlow.js +16 -18
- package/dist/{src/gateways → gateways}/EventBasedGateway.js +3 -4
- package/dist/{src/gateways → gateways}/ExclusiveGateway.js +2 -2
- package/dist/{src/gateways → gateways}/InclusiveGateway.js +2 -2
- package/dist/{src/gateways → gateways}/ParallelGateway.js +2 -2
- package/dist/index.js +48 -48
- package/dist/{src/io → io}/InputOutputSpecification.js +8 -9
- package/dist/{src/io → io}/Properties.js +7 -8
- package/dist/package.json +3 -0
- package/dist/{src/process → process}/Process.js +44 -40
- package/dist/{src/process → process}/ProcessExecution.js +169 -78
- package/dist/{src/tasks → tasks}/CallActivity.js +7 -8
- package/dist/{src/tasks → tasks}/LoopCharacteristics.js +2 -2
- package/dist/{src/tasks → tasks}/ReceiveTask.js +14 -15
- package/dist/{src/tasks → tasks}/ScriptTask.js +4 -4
- package/dist/{src/tasks → tasks}/ServiceImplementation.js +1 -1
- package/dist/{src/tasks → tasks}/ServiceTask.js +6 -7
- package/dist/{src/tasks → tasks}/SignalTask.js +7 -8
- package/dist/{src/tasks → tasks}/StandardLoopCharacteristics.js +1 -1
- package/dist/{src/tasks → tasks}/SubProcess.js +19 -19
- package/dist/{src/tasks → tasks}/Task.js +2 -2
- package/dist/{src/tasks → tasks}/Transaction.js +1 -1
- package/package.json +31 -31
- package/src/Api.js +11 -13
- package/src/Context.js +26 -28
- package/src/Environment.js +15 -17
- package/src/EventBroker.js +2 -1
- package/src/Expressions.js +1 -1
- package/src/MessageFormatter.js +3 -3
- package/src/Tracker.js +73 -0
- package/src/activity/Activity.js +106 -114
- package/src/activity/ActivityExecution.js +28 -32
- package/src/activity/Dummy.js +1 -1
- package/src/activity/ExecutionScope.js +2 -2
- package/src/definition/Definition.js +65 -64
- package/src/definition/DefinitionExecution.js +71 -47
- package/src/error/Errors.js +1 -1
- package/src/eventDefinitions/CancelEventDefinition.js +32 -78
- package/src/eventDefinitions/CompensateEventDefinition.js +58 -52
- package/src/eventDefinitions/ConditionalEventDefinition.js +25 -17
- package/src/eventDefinitions/ErrorEventDefinition.js +15 -15
- package/src/eventDefinitions/EscalationEventDefinition.js +12 -14
- package/src/eventDefinitions/EventDefinitionExecution.js +10 -12
- package/src/eventDefinitions/LinkEventDefinition.js +14 -16
- package/src/eventDefinitions/MessageEventDefinition.js +13 -15
- package/src/eventDefinitions/SignalEventDefinition.js +13 -15
- package/src/eventDefinitions/TerminateEventDefinition.js +1 -1
- package/src/eventDefinitions/TimerEventDefinition.js +15 -17
- package/src/events/BoundaryEvent.js +34 -24
- 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 +8 -10
- package/src/flows/Association.js +14 -26
- package/src/flows/MessageFlow.js +14 -15
- package/src/flows/SequenceFlow.js +16 -20
- package/src/gateways/EventBasedGateway.js +3 -4
- package/src/gateways/ExclusiveGateway.js +2 -2
- package/src/gateways/InclusiveGateway.js +2 -2
- package/src/gateways/ParallelGateway.js +2 -2
- package/src/index.js +106 -0
- package/src/io/InputOutputSpecification.js +8 -10
- package/src/io/Properties.js +7 -9
- package/src/process/Process.js +45 -41
- package/src/process/ProcessExecution.js +167 -79
- package/src/tasks/CallActivity.js +7 -9
- package/src/tasks/LoopCharacteristics.js +2 -2
- package/src/tasks/ReceiveTask.js +215 -217
- package/src/tasks/ScriptTask.js +4 -4
- package/src/tasks/ServiceImplementation.js +1 -1
- package/src/tasks/ServiceTask.js +6 -8
- package/src/tasks/SignalTask.js +7 -9
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +19 -20
- package/src/tasks/Task.js +2 -2
- package/src/tasks/Transaction.js +1 -1
- package/types/index.d.ts +520 -0
- package/dist/src/eventDefinitions/CancelEventDefinition.js +0 -184
- package/index.js +0 -106
- /package/dist/{src/ExtensionsMapper.js → ExtensionsMapper.js} +0 -0
- /package/dist/{src/Scripts.js → Scripts.js} +0 -0
- /package/dist/{src/Timers.js → Timers.js} +0 -0
- /package/dist/{src/activity → activity}/Escalation.js +0 -0
- /package/dist/{src/activity → activity}/Message.js +0 -0
- /package/dist/{src/activity → activity}/Signal.js +0 -0
- /package/dist/{src/error → error}/BpmnError.js +0 -0
- /package/dist/{src/getPropertyValue.js → getPropertyValue.js} +0 -0
- /package/dist/{src/io → io}/BpmnIO.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataObject.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataStore.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataStoreReference.js +0 -0
- /package/dist/{src/messageHelper.js → messageHelper.js} +0 -0
- /package/dist/{src/shared.js → shared.js} +0 -0
|
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _Api = require("../Api");
|
|
8
|
-
var _messageHelper = require("../messageHelper");
|
|
9
|
-
var _shared = require("../shared");
|
|
7
|
+
var _Api = require("../Api.js");
|
|
8
|
+
var _messageHelper = require("../messageHelper.js");
|
|
9
|
+
var _shared = require("../shared.js");
|
|
10
|
+
var _Tracker = require("../Tracker.js");
|
|
10
11
|
var _default = ProcessExecution;
|
|
11
12
|
exports.default = _default;
|
|
12
13
|
const kActivated = Symbol.for('activated');
|
|
@@ -18,17 +19,20 @@ const kMessageHandlers = Symbol.for('messageHandlers');
|
|
|
18
19
|
const kParent = Symbol.for('parent');
|
|
19
20
|
const kStatus = Symbol.for('status');
|
|
20
21
|
const kStopped = Symbol.for('stopped');
|
|
22
|
+
const kTracker = Symbol.for('activity tracker');
|
|
21
23
|
function ProcessExecution(parentActivity, context) {
|
|
22
24
|
const {
|
|
23
25
|
id,
|
|
24
26
|
type,
|
|
25
27
|
broker,
|
|
26
|
-
isSubProcess
|
|
28
|
+
isSubProcess,
|
|
29
|
+
isTransaction
|
|
27
30
|
} = parentActivity;
|
|
28
31
|
this[kParent] = parentActivity;
|
|
29
32
|
this.id = id;
|
|
30
33
|
this.type = type;
|
|
31
34
|
this.isSubProcess = isSubProcess;
|
|
35
|
+
this.isTransaction = isSubProcess && isTransaction;
|
|
32
36
|
this.broker = broker;
|
|
33
37
|
this.environment = context.environment;
|
|
34
38
|
this.context = context;
|
|
@@ -52,6 +56,7 @@ function ProcessExecution(parentActivity, context) {
|
|
|
52
56
|
this[kStopped] = false;
|
|
53
57
|
this[kActivated] = false;
|
|
54
58
|
this[kStatus] = 'init';
|
|
59
|
+
this[kTracker] = new _Tracker.ActivityTracker(id);
|
|
55
60
|
this.executionId = undefined;
|
|
56
61
|
this[kMessageHandlers] = {
|
|
57
62
|
onActivityEvent: this._onActivityEvent.bind(this),
|
|
@@ -60,36 +65,40 @@ function ProcessExecution(parentActivity, context) {
|
|
|
60
65
|
onMessageFlowEvent: this._onMessageFlowEvent.bind(this)
|
|
61
66
|
};
|
|
62
67
|
}
|
|
63
|
-
|
|
64
|
-
Object.defineProperty(proto, 'stopped', {
|
|
68
|
+
Object.defineProperty(ProcessExecution.prototype, 'stopped', {
|
|
65
69
|
enumerable: true,
|
|
66
70
|
get() {
|
|
67
71
|
return this[kStopped];
|
|
68
72
|
}
|
|
69
73
|
});
|
|
70
|
-
Object.defineProperty(
|
|
74
|
+
Object.defineProperty(ProcessExecution.prototype, 'completed', {
|
|
71
75
|
enumerable: true,
|
|
72
76
|
get() {
|
|
73
77
|
return this[kCompleted];
|
|
74
78
|
}
|
|
75
79
|
});
|
|
76
|
-
Object.defineProperty(
|
|
80
|
+
Object.defineProperty(ProcessExecution.prototype, 'status', {
|
|
77
81
|
enumerable: true,
|
|
78
82
|
get() {
|
|
79
83
|
return this[kStatus];
|
|
80
84
|
}
|
|
81
85
|
});
|
|
82
|
-
Object.defineProperty(
|
|
86
|
+
Object.defineProperty(ProcessExecution.prototype, 'postponedCount', {
|
|
83
87
|
get() {
|
|
84
88
|
return this[kElements].postponed.length;
|
|
85
89
|
}
|
|
86
90
|
});
|
|
87
|
-
Object.defineProperty(
|
|
91
|
+
Object.defineProperty(ProcessExecution.prototype, 'isRunning', {
|
|
88
92
|
get() {
|
|
89
93
|
return this[kActivated];
|
|
90
94
|
}
|
|
91
95
|
});
|
|
92
|
-
|
|
96
|
+
Object.defineProperty(ProcessExecution.prototype, 'activityStatus', {
|
|
97
|
+
get() {
|
|
98
|
+
return this[kTracker].activityStatus;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
ProcessExecution.prototype.execute = function execute(executeMessage) {
|
|
93
102
|
if (!executeMessage) throw new Error('Process execution requires message');
|
|
94
103
|
if (!executeMessage.content || !executeMessage.content.executionId) throw new Error('Process execution requires execution id');
|
|
95
104
|
const executionId = this.executionId = executeMessage.content.executionId;
|
|
@@ -111,7 +120,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
111
120
|
this._start();
|
|
112
121
|
return true;
|
|
113
122
|
};
|
|
114
|
-
|
|
123
|
+
ProcessExecution.prototype.resume = function resume() {
|
|
115
124
|
this._debug(`resume process execution at ${this.status}`);
|
|
116
125
|
if (this[kCompleted]) return this._complete('completed');
|
|
117
126
|
this._activate();
|
|
@@ -132,6 +141,7 @@ proto.resume = function resume() {
|
|
|
132
141
|
if (this[kCompleted]) return;
|
|
133
142
|
const status = this.status;
|
|
134
143
|
if (status === 'init') return this._start();
|
|
144
|
+
const tracker = this[kTracker];
|
|
135
145
|
for (const msg of postponed.slice()) {
|
|
136
146
|
const activity = this.getActivityById(msg.content.id);
|
|
137
147
|
if (!activity) continue;
|
|
@@ -141,12 +151,13 @@ proto.resume = function resume() {
|
|
|
141
151
|
msg.ack();
|
|
142
152
|
continue;
|
|
143
153
|
}
|
|
154
|
+
tracker.track(msg.fields.routingKey, msg);
|
|
144
155
|
activity.resume();
|
|
145
156
|
}
|
|
146
157
|
if (this[kCompleted]) return;
|
|
147
158
|
if (!postponed.length && status === 'executing') return this._complete('completed');
|
|
148
159
|
};
|
|
149
|
-
|
|
160
|
+
ProcessExecution.prototype.recover = function recover(state) {
|
|
150
161
|
if (!state) return this;
|
|
151
162
|
this.executionId = state.executionId;
|
|
152
163
|
this[kStopped] = state.stopped;
|
|
@@ -183,7 +194,7 @@ proto.recover = function recover(state) {
|
|
|
183
194
|
}
|
|
184
195
|
return this;
|
|
185
196
|
};
|
|
186
|
-
|
|
197
|
+
ProcessExecution.prototype.shake = function shake(fromId) {
|
|
187
198
|
let executing = true;
|
|
188
199
|
const id = this.id;
|
|
189
200
|
if (!this.isRunning) {
|
|
@@ -224,10 +235,10 @@ proto.shake = function shake(fromId) {
|
|
|
224
235
|
this.broker.cancel(`_shaker-${this.executionId}`);
|
|
225
236
|
return result;
|
|
226
237
|
};
|
|
227
|
-
|
|
238
|
+
ProcessExecution.prototype.stop = function stop() {
|
|
228
239
|
this.getApi().stop();
|
|
229
240
|
};
|
|
230
|
-
|
|
241
|
+
ProcessExecution.prototype.getPostponed = function getPostponed(filterFn) {
|
|
231
242
|
const result = [];
|
|
232
243
|
for (const msg of this[kElements].postponed.slice()) {
|
|
233
244
|
const api = this._getChildApi(msg);
|
|
@@ -237,7 +248,7 @@ proto.getPostponed = function getPostponed(filterFn) {
|
|
|
237
248
|
}
|
|
238
249
|
return result;
|
|
239
250
|
};
|
|
240
|
-
|
|
251
|
+
ProcessExecution.prototype.discard = function discard() {
|
|
241
252
|
this[kStatus] = 'discard';
|
|
242
253
|
return this[kActivityQ].queueMessage({
|
|
243
254
|
routingKey: 'execution.discard'
|
|
@@ -249,7 +260,18 @@ proto.discard = function discard() {
|
|
|
249
260
|
type: 'discard'
|
|
250
261
|
});
|
|
251
262
|
};
|
|
252
|
-
|
|
263
|
+
ProcessExecution.prototype.cancel = function discard() {
|
|
264
|
+
return this[kActivityQ].queueMessage({
|
|
265
|
+
routingKey: 'execution.cancel'
|
|
266
|
+
}, {
|
|
267
|
+
id: this.id,
|
|
268
|
+
type: this.type,
|
|
269
|
+
executionId: this.executionId
|
|
270
|
+
}, {
|
|
271
|
+
type: 'cancel'
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
ProcessExecution.prototype.getState = function getState() {
|
|
253
275
|
const {
|
|
254
276
|
children,
|
|
255
277
|
flows,
|
|
@@ -277,16 +299,19 @@ proto.getState = function getState() {
|
|
|
277
299
|
})
|
|
278
300
|
};
|
|
279
301
|
};
|
|
280
|
-
|
|
302
|
+
ProcessExecution.prototype.getActivities = function getActivities() {
|
|
281
303
|
return this[kElements].children.slice();
|
|
282
304
|
};
|
|
283
|
-
|
|
305
|
+
ProcessExecution.prototype.getActivityById = function getActivityById(activityId) {
|
|
284
306
|
return this[kElements].children.find(child => child.id === activityId);
|
|
285
307
|
};
|
|
286
|
-
|
|
308
|
+
ProcessExecution.prototype.getSequenceFlows = function getSequenceFlows() {
|
|
287
309
|
return this[kElements].flows.slice();
|
|
288
310
|
};
|
|
289
|
-
|
|
311
|
+
ProcessExecution.prototype.getAssociations = function getAssociations() {
|
|
312
|
+
return this[kElements].associations.slice();
|
|
313
|
+
};
|
|
314
|
+
ProcessExecution.prototype.getApi = function getApi(message) {
|
|
290
315
|
if (!message) return (0, _Api.ProcessApi)(this.broker, this[kExecuteMessage]);
|
|
291
316
|
const content = message.content;
|
|
292
317
|
if (content.executionId !== this.executionId) {
|
|
@@ -304,7 +329,7 @@ proto.getApi = function getApi(message) {
|
|
|
304
329
|
};
|
|
305
330
|
return api;
|
|
306
331
|
};
|
|
307
|
-
|
|
332
|
+
ProcessExecution.prototype._start = function start() {
|
|
308
333
|
if (this[kElements].children.length === 0) {
|
|
309
334
|
return this._complete('completed');
|
|
310
335
|
}
|
|
@@ -323,6 +348,7 @@ proto._start = function start() {
|
|
|
323
348
|
for (const a of startActivities) a.shake();
|
|
324
349
|
}
|
|
325
350
|
for (const a of startActivities) a.init();
|
|
351
|
+
this[kStatus] = 'executing';
|
|
326
352
|
for (const a of startActivities) a.run();
|
|
327
353
|
postponed.splice(0);
|
|
328
354
|
detachedActivities.splice(0);
|
|
@@ -331,7 +357,7 @@ proto._start = function start() {
|
|
|
331
357
|
consumerTag: `_process-activity-${this.executionId}`
|
|
332
358
|
});
|
|
333
359
|
};
|
|
334
|
-
|
|
360
|
+
ProcessExecution.prototype._activate = function activate() {
|
|
335
361
|
const {
|
|
336
362
|
onApiMessage,
|
|
337
363
|
onMessageFlowEvent,
|
|
@@ -395,7 +421,7 @@ proto._activate = function activate() {
|
|
|
395
421
|
}
|
|
396
422
|
this[kActivated] = true;
|
|
397
423
|
};
|
|
398
|
-
|
|
424
|
+
ProcessExecution.prototype._deactivate = function deactivate() {
|
|
399
425
|
const broker = this.broker;
|
|
400
426
|
const executionId = this.executionId;
|
|
401
427
|
broker.cancel(`_process-api-consumer-${executionId}`);
|
|
@@ -423,7 +449,7 @@ proto._deactivate = function deactivate() {
|
|
|
423
449
|
}
|
|
424
450
|
this[kActivated] = false;
|
|
425
451
|
};
|
|
426
|
-
|
|
452
|
+
ProcessExecution.prototype._onDelegateEvent = function onDelegateEvent(message) {
|
|
427
453
|
const eventType = message.properties.type;
|
|
428
454
|
let delegate = true;
|
|
429
455
|
const content = message.content;
|
|
@@ -446,10 +472,10 @@ proto._onDelegateEvent = function onDelegateEvent(message) {
|
|
|
446
472
|
});
|
|
447
473
|
return delegate;
|
|
448
474
|
};
|
|
449
|
-
|
|
475
|
+
ProcessExecution.prototype._onMessageFlowEvent = function onMessageFlowEvent(routingKey, message) {
|
|
450
476
|
this.broker.publish('message', routingKey, (0, _messageHelper.cloneContent)(message.content), message.properties);
|
|
451
477
|
};
|
|
452
|
-
|
|
478
|
+
ProcessExecution.prototype._onActivityEvent = function onActivityEvent(routingKey, message) {
|
|
453
479
|
if (message.fields.redelivered && message.properties.persistent === false) return;
|
|
454
480
|
const content = message.content;
|
|
455
481
|
const parent = content.parent = content.parent || {};
|
|
@@ -466,6 +492,7 @@ proto._onActivityEvent = function onActivityEvent(routingKey, message) {
|
|
|
466
492
|
});
|
|
467
493
|
}
|
|
468
494
|
if (delegate) delegate = this._onDelegateEvent(message);
|
|
495
|
+
this[kTracker].track(routingKey, message);
|
|
469
496
|
this.broker.publish('event', routingKey, content, {
|
|
470
497
|
...message.properties,
|
|
471
498
|
delegate,
|
|
@@ -473,7 +500,6 @@ proto._onActivityEvent = function onActivityEvent(routingKey, message) {
|
|
|
473
500
|
});
|
|
474
501
|
if (shaking) return this._onShookEnd(message);
|
|
475
502
|
if (!isDirectChild) return;
|
|
476
|
-
if (content.isAssociation) return;
|
|
477
503
|
switch (routingKey) {
|
|
478
504
|
case 'process.terminate':
|
|
479
505
|
return this[kActivityQ].queueMessage({
|
|
@@ -490,7 +516,7 @@ proto._onActivityEvent = function onActivityEvent(routingKey, message) {
|
|
|
490
516
|
...message.properties
|
|
491
517
|
});
|
|
492
518
|
};
|
|
493
|
-
|
|
519
|
+
ProcessExecution.prototype._onChildMessage = function onChildMessage(routingKey, message) {
|
|
494
520
|
if (message.fields.redelivered && message.properties.persistent === false) return message.ack();
|
|
495
521
|
const content = message.content;
|
|
496
522
|
switch (routingKey) {
|
|
@@ -503,6 +529,17 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
|
|
|
503
529
|
case 'execution.discard':
|
|
504
530
|
message.ack();
|
|
505
531
|
return this._onDiscard(message);
|
|
532
|
+
case 'execution.discard.detached':
|
|
533
|
+
{
|
|
534
|
+
message.ack();
|
|
535
|
+
for (const detached of this[kElements].detachedActivities) {
|
|
536
|
+
this._getChildApi(detached).discard();
|
|
537
|
+
}
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
case 'execution.cancel':
|
|
541
|
+
message.ack();
|
|
542
|
+
return this._onCancel(message);
|
|
506
543
|
case 'activity.error.caught':
|
|
507
544
|
{
|
|
508
545
|
const prevMsg = this[kElements].postponed.find(msg => {
|
|
@@ -511,7 +548,6 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
|
|
|
511
548
|
if (!prevMsg) return message.ack();
|
|
512
549
|
break;
|
|
513
550
|
}
|
|
514
|
-
case 'activity.compensation.end':
|
|
515
551
|
case 'flow.looped':
|
|
516
552
|
case 'activity.leave':
|
|
517
553
|
return this._onChildCompleted(message);
|
|
@@ -523,14 +559,17 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
|
|
|
523
559
|
this[kElements].detachedActivities.push((0, _messageHelper.cloneMessage)(message));
|
|
524
560
|
break;
|
|
525
561
|
}
|
|
562
|
+
case 'activity.cancel':
|
|
563
|
+
{
|
|
564
|
+
if (this.isTransaction) this._onCancel(message);
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
526
567
|
case 'activity.discard':
|
|
527
|
-
case 'activity.compensation.start':
|
|
528
568
|
case 'activity.enter':
|
|
529
569
|
{
|
|
530
|
-
this[kStatus] = 'executing';
|
|
531
570
|
if (!content.inbound) break;
|
|
532
571
|
for (const inbound of content.inbound) {
|
|
533
|
-
if (!inbound.isSequenceFlow) continue;
|
|
572
|
+
if (!inbound.isSequenceFlow && !inbound.isAssociation) continue;
|
|
534
573
|
const inboundMessage = this._popPostponed(inbound);
|
|
535
574
|
if (inboundMessage) inboundMessage.ack();
|
|
536
575
|
}
|
|
@@ -557,18 +596,18 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
|
|
|
557
596
|
}
|
|
558
597
|
}
|
|
559
598
|
};
|
|
560
|
-
|
|
599
|
+
ProcessExecution.prototype._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
|
|
561
600
|
const previousMsg = this._popPostponed(message.content);
|
|
562
601
|
if (previousMsg) previousMsg.ack();
|
|
563
602
|
if (postponeMessage) this[kElements].postponed.push(message);
|
|
564
603
|
};
|
|
565
|
-
|
|
604
|
+
ProcessExecution.prototype._popPostponed = function popPostponed(byContent) {
|
|
566
605
|
const {
|
|
567
606
|
postponed,
|
|
568
607
|
detachedActivities
|
|
569
608
|
} = this[kElements];
|
|
570
609
|
const postponedIdx = postponed.findIndex(msg => {
|
|
571
|
-
if (msg.content.isSequenceFlow) return msg.content.sequenceId === byContent.sequenceId;
|
|
610
|
+
if (msg.content.isSequenceFlow || msg.content.isAssociation) return msg.content.sequenceId === byContent.sequenceId;
|
|
572
611
|
return msg.content.executionId === byContent.executionId;
|
|
573
612
|
});
|
|
574
613
|
let postponedMsg;
|
|
@@ -579,7 +618,7 @@ proto._popPostponed = function popPostponed(byContent) {
|
|
|
579
618
|
if (detachedIdx > -1) detachedActivities.splice(detachedIdx, 1);
|
|
580
619
|
return postponedMsg;
|
|
581
620
|
};
|
|
582
|
-
|
|
621
|
+
ProcessExecution.prototype._onChildCompleted = function onChildCompleted(message) {
|
|
583
622
|
this._stateChangeMessage(message, false);
|
|
584
623
|
if (message.fields.redelivered) return message.ack();
|
|
585
624
|
const {
|
|
@@ -599,9 +638,16 @@ proto._onChildCompleted = function onChildCompleted(message) {
|
|
|
599
638
|
return this._complete('completed');
|
|
600
639
|
}
|
|
601
640
|
this._debug(`left <${id}> (${type}), pending runs ${postponedCount}, ${postponed.map(a => a.content.id).join(',')}`);
|
|
602
|
-
if (postponedCount === detachedActivities.length) {
|
|
603
|
-
|
|
604
|
-
|
|
641
|
+
if (postponedCount && postponedCount === detachedActivities.length) {
|
|
642
|
+
return this[kActivityQ].queueMessage({
|
|
643
|
+
routingKey: 'execution.discard.detached'
|
|
644
|
+
}, {
|
|
645
|
+
id: this.id,
|
|
646
|
+
type: this.type,
|
|
647
|
+
executionId: this.executionId
|
|
648
|
+
}, {
|
|
649
|
+
type: 'cancel'
|
|
650
|
+
});
|
|
605
651
|
}
|
|
606
652
|
if (isEnd && startActivities.length) {
|
|
607
653
|
const startSequences = this[kElements].startSequences;
|
|
@@ -618,7 +664,7 @@ proto._onChildCompleted = function onChildCompleted(message) {
|
|
|
618
664
|
}
|
|
619
665
|
}
|
|
620
666
|
};
|
|
621
|
-
|
|
667
|
+
ProcessExecution.prototype._stopExecution = function stopExecution(message) {
|
|
622
668
|
const postponedCount = this.postponedCount;
|
|
623
669
|
this._debug(`stop process execution (stop child executions ${postponedCount})`);
|
|
624
670
|
if (postponedCount) {
|
|
@@ -634,37 +680,46 @@ proto._stopExecution = function stopExecution(message) {
|
|
|
634
680
|
persistent: false
|
|
635
681
|
});
|
|
636
682
|
};
|
|
637
|
-
|
|
683
|
+
ProcessExecution.prototype._onDiscard = function onDiscard() {
|
|
638
684
|
this._deactivate();
|
|
639
685
|
const running = this[kElements].postponed.splice(0);
|
|
640
686
|
this._debug(`discard process execution (discard child executions ${running.length})`);
|
|
641
|
-
|
|
642
|
-
|
|
687
|
+
if (this.isSubProcess) {
|
|
688
|
+
this.stop();
|
|
689
|
+
} else {
|
|
690
|
+
for (const flow of this.getSequenceFlows()) flow.stop();
|
|
691
|
+
for (const flow of this.getAssociations()) flow.stop();
|
|
692
|
+
for (const msg of running) this._getChildApi(msg).discard();
|
|
693
|
+
}
|
|
643
694
|
this[kActivityQ].purge();
|
|
644
695
|
return this._complete('discard');
|
|
645
696
|
};
|
|
646
|
-
|
|
647
|
-
const
|
|
648
|
-
const
|
|
649
|
-
if (
|
|
650
|
-
|
|
651
|
-
this
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
697
|
+
ProcessExecution.prototype._onCancel = function onCancel() {
|
|
698
|
+
const running = this[kElements].postponed.slice(0);
|
|
699
|
+
const isTransaction = this.isTransaction;
|
|
700
|
+
if (isTransaction) {
|
|
701
|
+
this._debug(`cancel transaction execution (cancel child executions ${running.length})`);
|
|
702
|
+
this[kStatus] = 'cancel';
|
|
703
|
+
this.broker.publish('event', 'transaction.cancel', (0, _messageHelper.cloneMessage)(this[kExecuteMessage], {
|
|
704
|
+
state: 'cancel'
|
|
705
|
+
}));
|
|
706
|
+
for (const msg of running) {
|
|
707
|
+
if (msg.content.expect === 'compensate') {
|
|
708
|
+
this._getChildApi(msg).sendApiMessage('compensate');
|
|
709
|
+
} else if (!msg.content.isForCompensation) {
|
|
710
|
+
this._getChildApi(msg).discard();
|
|
657
711
|
}
|
|
658
|
-
}, {
|
|
659
|
-
consumerTag: `_ct-delegate-${correlationId}`,
|
|
660
|
-
noAck: true
|
|
661
|
-
});
|
|
662
|
-
for (const child of this[kElements].children) {
|
|
663
|
-
if (child.placeholder) continue;
|
|
664
|
-
child.broker.publish('api', routingKey, (0, _messageHelper.cloneContent)(message.content), message.properties);
|
|
665
|
-
if (consumed) break;
|
|
666
712
|
}
|
|
667
|
-
|
|
713
|
+
} else {
|
|
714
|
+
this._debug(`cancel process execution (cancel child executions ${running.length})`);
|
|
715
|
+
for (const msg of running) {
|
|
716
|
+
this._getChildApi(msg).discard();
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
ProcessExecution.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
721
|
+
if (message.properties.delegate) {
|
|
722
|
+
return this._delegateApiMessage(routingKey, message);
|
|
668
723
|
}
|
|
669
724
|
if (this.id !== message.content.id) {
|
|
670
725
|
const child = this.getActivityById(message.content.id);
|
|
@@ -673,6 +728,8 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
673
728
|
}
|
|
674
729
|
if (this.executionId !== message.content.executionId) return;
|
|
675
730
|
switch (message.properties.type) {
|
|
731
|
+
case 'cancel':
|
|
732
|
+
return this.cancel(message);
|
|
676
733
|
case 'discard':
|
|
677
734
|
return this.discard(message);
|
|
678
735
|
case 'stop':
|
|
@@ -684,11 +741,43 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
684
741
|
break;
|
|
685
742
|
}
|
|
686
743
|
};
|
|
687
|
-
|
|
744
|
+
ProcessExecution.prototype._delegateApiMessage = function delegateApiMessage(routingKey, message, continueOnConsumed) {
|
|
745
|
+
const correlationId = message.properties.correlationId || (0, _shared.getUniqueId)(this.executionId);
|
|
746
|
+
this._debug(`delegate api ${routingKey} message to children, with correlationId <${correlationId}>`);
|
|
747
|
+
const broker = this.broker;
|
|
748
|
+
let consumed = false;
|
|
749
|
+
broker.subscribeTmp('event', 'activity.consumed', (_, msg) => {
|
|
750
|
+
if (msg.properties.correlationId === correlationId) {
|
|
751
|
+
consumed = true;
|
|
752
|
+
this._debug(`delegated api message was consumed by ${msg.content ? msg.content.executionId : 'unknown'}`);
|
|
753
|
+
}
|
|
754
|
+
}, {
|
|
755
|
+
consumerTag: `_ct-delegate-${correlationId}`,
|
|
756
|
+
noAck: true
|
|
757
|
+
});
|
|
758
|
+
for (const child of this[kElements].children) {
|
|
759
|
+
if (child.placeholder) continue;
|
|
760
|
+
child.broker.publish('api', routingKey, (0, _messageHelper.cloneContent)(message.content), message.properties);
|
|
761
|
+
if (consumed && !continueOnConsumed) break;
|
|
762
|
+
}
|
|
763
|
+
return broker.cancel(`_ct-delegate-${correlationId}`);
|
|
764
|
+
};
|
|
765
|
+
ProcessExecution.prototype._complete = function complete(completionType, content) {
|
|
688
766
|
this._deactivate();
|
|
689
|
-
this._debug(`process execution ${completionType}`);
|
|
690
767
|
this[kCompleted] = true;
|
|
691
|
-
|
|
768
|
+
const status = this.status;
|
|
769
|
+
switch (this.status) {
|
|
770
|
+
case 'cancel':
|
|
771
|
+
this._debug('process execution cancelled');
|
|
772
|
+
case 'discard':
|
|
773
|
+
completionType = status;
|
|
774
|
+
break;
|
|
775
|
+
case 'terminated':
|
|
776
|
+
break;
|
|
777
|
+
default:
|
|
778
|
+
this._debug(`process execution ${completionType}`);
|
|
779
|
+
this[kStatus] = completionType;
|
|
780
|
+
}
|
|
692
781
|
const broker = this.broker;
|
|
693
782
|
this[kActivityQ].delete();
|
|
694
783
|
return broker.publish(this._exchangeName, `execution.${completionType}.${this.executionId}`, (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
|
|
@@ -702,36 +791,38 @@ proto._complete = function complete(completionType, content) {
|
|
|
702
791
|
mandatory: completionType === 'error'
|
|
703
792
|
});
|
|
704
793
|
};
|
|
705
|
-
|
|
794
|
+
ProcessExecution.prototype._terminate = function terminate(message) {
|
|
706
795
|
this[kStatus] = 'terminated';
|
|
707
796
|
this._debug('terminating process execution');
|
|
708
797
|
const running = this[kElements].postponed.splice(0);
|
|
709
798
|
for (const flow of this.getSequenceFlows()) flow.stop();
|
|
799
|
+
for (const flow of this.getAssociations()) flow.stop();
|
|
710
800
|
for (const msg of running) {
|
|
711
801
|
const {
|
|
712
802
|
id: postponedId,
|
|
713
|
-
isSequenceFlow
|
|
803
|
+
isSequenceFlow,
|
|
804
|
+
isAssociation
|
|
714
805
|
} = msg.content;
|
|
715
806
|
if (postponedId === message.content.id) continue;
|
|
716
|
-
if (isSequenceFlow) continue;
|
|
807
|
+
if (isSequenceFlow || isAssociation) continue;
|
|
717
808
|
this._getChildApi(msg).stop();
|
|
718
809
|
msg.ack();
|
|
719
810
|
}
|
|
720
811
|
this[kActivityQ].purge();
|
|
721
812
|
};
|
|
722
|
-
|
|
813
|
+
ProcessExecution.prototype._getFlowById = function getFlowById(flowId) {
|
|
723
814
|
return this[kElements].flows.find(f => f.id === flowId);
|
|
724
815
|
};
|
|
725
|
-
|
|
816
|
+
ProcessExecution.prototype._getAssociationById = function getAssociationById(associationId) {
|
|
726
817
|
return this[kElements].associations.find(a => a.id === associationId);
|
|
727
818
|
};
|
|
728
|
-
|
|
819
|
+
ProcessExecution.prototype._getMessageFlowById = function getMessageFlowById(flowId) {
|
|
729
820
|
return this[kElements].outboundMessageFlows.find(f => f.id === flowId);
|
|
730
821
|
};
|
|
731
|
-
|
|
822
|
+
ProcessExecution.prototype._getChildById = function getChildById(childId) {
|
|
732
823
|
return this.getActivityById(childId) || this._getFlowById(childId);
|
|
733
824
|
};
|
|
734
|
-
|
|
825
|
+
ProcessExecution.prototype._getChildApi = function getChildApi(message) {
|
|
735
826
|
const content = message.content;
|
|
736
827
|
let child = this._getChildById(content.id);
|
|
737
828
|
if (child) return child.getApi(message);
|
|
@@ -744,11 +835,11 @@ proto._getChildApi = function getChildApi(message) {
|
|
|
744
835
|
if (child) return child.getApi(message);
|
|
745
836
|
}
|
|
746
837
|
};
|
|
747
|
-
|
|
838
|
+
ProcessExecution.prototype._onShookEnd = function onShookEnd(message) {
|
|
748
839
|
const routingKey = message.fields.routingKey;
|
|
749
840
|
if (routingKey !== 'activity.shake.end') return;
|
|
750
841
|
this[kElements].startSequences[message.content.id] = (0, _messageHelper.cloneMessage)(message);
|
|
751
842
|
};
|
|
752
|
-
|
|
843
|
+
ProcessExecution.prototype._debug = function debugMessage(logMessage) {
|
|
753
844
|
this[kParent].logger.debug(`<${this.executionId} (${this.id})> ${logMessage}`);
|
|
754
845
|
};
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.CallActivityBehaviour = CallActivityBehaviour;
|
|
7
7
|
exports.default = CallActivity;
|
|
8
|
-
var _Activity = _interopRequireDefault(require("../activity/Activity"));
|
|
9
|
-
var _Errors = require("../error/Errors");
|
|
10
|
-
var _messageHelper = require("../messageHelper");
|
|
8
|
+
var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
|
|
9
|
+
var _Errors = require("../error/Errors.js");
|
|
10
|
+
var _messageHelper = require("../messageHelper.js");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
function CallActivity(activityDef, context) {
|
|
13
13
|
return new _Activity.default(CallActivityBehaviour, activityDef, context);
|
|
@@ -26,8 +26,7 @@ function CallActivityBehaviour(activity) {
|
|
|
26
26
|
this.broker = activity.broker;
|
|
27
27
|
this.environment = activity.environment;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
proto.execute = function execute(executeMessage) {
|
|
29
|
+
CallActivityBehaviour.prototype.execute = function execute(executeMessage) {
|
|
31
30
|
const executeContent = executeMessage.content;
|
|
32
31
|
const loopCharacteristics = this.loopCharacteristics;
|
|
33
32
|
if (loopCharacteristics && executeContent.isRootScope) {
|
|
@@ -62,7 +61,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
62
61
|
type: 'call'
|
|
63
62
|
});
|
|
64
63
|
};
|
|
65
|
-
|
|
64
|
+
CallActivityBehaviour.prototype._onDelegatedApiMessage = function onDelegatedApiMessage(calledElement, executeMessage, routingKey, message) {
|
|
66
65
|
if (!message.properties.delegate) return;
|
|
67
66
|
const {
|
|
68
67
|
content: delegateContent
|
|
@@ -89,7 +88,7 @@ proto._onDelegatedApiMessage = function onDelegatedApiMessage(calledElement, exe
|
|
|
89
88
|
});
|
|
90
89
|
return this._onApiMessage(calledElement, executeMessage, routingKey, message);
|
|
91
90
|
};
|
|
92
|
-
|
|
91
|
+
CallActivityBehaviour.prototype._onApiMessage = function onApiMessage(calledElement, executeMessage, routingKey, message) {
|
|
93
92
|
const {
|
|
94
93
|
type: messageType,
|
|
95
94
|
correlationId
|
|
@@ -132,7 +131,7 @@ proto._onApiMessage = function onApiMessage(calledElement, executeMessage, routi
|
|
|
132
131
|
});
|
|
133
132
|
}
|
|
134
133
|
};
|
|
135
|
-
|
|
134
|
+
CallActivityBehaviour.prototype._stop = function stop(executionId) {
|
|
136
135
|
const broker = this.broker;
|
|
137
136
|
broker.cancel(`_api-${executionId}`);
|
|
138
137
|
broker.cancel(`_api-delegated-${executionId}`);
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = LoopCharacteristics;
|
|
7
|
-
var _Errors = require("../error/Errors");
|
|
8
|
-
var _messageHelper = require("../messageHelper");
|
|
7
|
+
var _Errors = require("../error/Errors.js");
|
|
8
|
+
var _messageHelper = require("../messageHelper.js");
|
|
9
9
|
function LoopCharacteristics(activity, loopCharacteristics) {
|
|
10
10
|
this.activity = activity;
|
|
11
11
|
this.loopCharacteristics = loopCharacteristics;
|