bpmn-elements 7.0.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -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 +91 -91
- package/dist/src/activity/ActivityExecution.js +35 -35
- 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 +21 -21
- package/dist/src/events/BoundaryEvent.js +20 -20
- 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 +9 -9
- 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 +91 -91
- package/src/activity/ActivityExecution.js +34 -34
- 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 +21 -21
- package/src/events/BoundaryEvent.js +20 -20
- 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
|
@@ -13,15 +13,15 @@ var _shared = require("../shared");
|
|
|
13
13
|
|
|
14
14
|
var _default = ProcessExecution;
|
|
15
15
|
exports.default = _default;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
16
|
+
const kActivated = Symbol.for('activated');
|
|
17
|
+
const kActivityQ = Symbol.for('activityQ');
|
|
18
|
+
const kCompleted = Symbol.for('completed');
|
|
19
|
+
const kElements = Symbol.for('elements');
|
|
20
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
21
|
+
const kMessageHandlers = Symbol.for('messageHandlers');
|
|
22
|
+
const kParent = Symbol.for('parent');
|
|
23
|
+
const kStatus = Symbol.for('status');
|
|
24
|
+
const kStopped = Symbol.for('stopped');
|
|
25
25
|
|
|
26
26
|
function ProcessExecution(parentActivity, context) {
|
|
27
27
|
const {
|
|
@@ -30,14 +30,14 @@ function ProcessExecution(parentActivity, context) {
|
|
|
30
30
|
broker,
|
|
31
31
|
isSubProcess
|
|
32
32
|
} = parentActivity;
|
|
33
|
-
this[
|
|
33
|
+
this[kParent] = parentActivity;
|
|
34
34
|
this.id = id;
|
|
35
35
|
this.type = type;
|
|
36
36
|
this.isSubProcess = isSubProcess;
|
|
37
37
|
this.broker = broker;
|
|
38
38
|
this.environment = context.environment;
|
|
39
39
|
this.context = context;
|
|
40
|
-
this[
|
|
40
|
+
this[kElements] = {
|
|
41
41
|
children: context.getActivities(id),
|
|
42
42
|
associations: context.getAssociations(id),
|
|
43
43
|
flows: context.getSequenceFlows(id),
|
|
@@ -53,12 +53,12 @@ function ProcessExecution(parentActivity, context) {
|
|
|
53
53
|
autoDelete: false,
|
|
54
54
|
durable: true
|
|
55
55
|
});
|
|
56
|
-
this[
|
|
57
|
-
this[
|
|
58
|
-
this[
|
|
59
|
-
this[
|
|
56
|
+
this[kCompleted] = false;
|
|
57
|
+
this[kStopped] = false;
|
|
58
|
+
this[kActivated] = false;
|
|
59
|
+
this[kStatus] = 'init';
|
|
60
60
|
this.executionId = undefined;
|
|
61
|
-
this[
|
|
61
|
+
this[kMessageHandlers] = {
|
|
62
62
|
onActivityEvent: this._onActivityEvent.bind(this),
|
|
63
63
|
onApiMessage: this._onApiMessage.bind(this),
|
|
64
64
|
onChildMessage: this._onChildMessage.bind(this),
|
|
@@ -71,7 +71,7 @@ Object.defineProperty(proto, 'stopped', {
|
|
|
71
71
|
enumerable: true,
|
|
72
72
|
|
|
73
73
|
get() {
|
|
74
|
-
return this[
|
|
74
|
+
return this[kStopped];
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
});
|
|
@@ -79,7 +79,7 @@ Object.defineProperty(proto, 'completed', {
|
|
|
79
79
|
enumerable: true,
|
|
80
80
|
|
|
81
81
|
get() {
|
|
82
|
-
return this[
|
|
82
|
+
return this[kCompleted];
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
});
|
|
@@ -87,19 +87,19 @@ Object.defineProperty(proto, 'status', {
|
|
|
87
87
|
enumerable: true,
|
|
88
88
|
|
|
89
89
|
get() {
|
|
90
|
-
return this[
|
|
90
|
+
return this[kStatus];
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
});
|
|
94
94
|
Object.defineProperty(proto, 'postponedCount', {
|
|
95
95
|
get() {
|
|
96
|
-
return this[
|
|
96
|
+
return this[kElements].postponed.length;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
});
|
|
100
100
|
Object.defineProperty(proto, 'isRunning', {
|
|
101
101
|
get() {
|
|
102
|
-
return this[
|
|
102
|
+
return this[kActivated];
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
});
|
|
@@ -108,13 +108,13 @@ proto.execute = function execute(executeMessage) {
|
|
|
108
108
|
if (!executeMessage) throw new Error('Process execution requires message');
|
|
109
109
|
if (!executeMessage.content || !executeMessage.content.executionId) throw new Error('Process execution requires execution id');
|
|
110
110
|
const executionId = this.executionId = executeMessage.content.executionId;
|
|
111
|
-
this[
|
|
111
|
+
this[kExecuteMessage] = (0, _messageHelper.cloneMessage)(executeMessage, {
|
|
112
112
|
executionId,
|
|
113
113
|
state: 'start'
|
|
114
114
|
});
|
|
115
|
-
this[
|
|
115
|
+
this[kStopped] = false;
|
|
116
116
|
this.environment.assignVariables(executeMessage);
|
|
117
|
-
this[
|
|
117
|
+
this[kActivityQ] = this.broker.assertQueue(`execute-${executionId}-q`, {
|
|
118
118
|
durable: true,
|
|
119
119
|
autoDelete: false
|
|
120
120
|
});
|
|
@@ -135,7 +135,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
135
135
|
proto.resume = function resume() {
|
|
136
136
|
this._debug(`resume process execution at ${this.status}`);
|
|
137
137
|
|
|
138
|
-
if (this[
|
|
138
|
+
if (this[kCompleted]) return this._complete('completed');
|
|
139
139
|
|
|
140
140
|
this._activate();
|
|
141
141
|
|
|
@@ -143,7 +143,7 @@ proto.resume = function resume() {
|
|
|
143
143
|
startActivities,
|
|
144
144
|
detachedActivities,
|
|
145
145
|
postponed
|
|
146
|
-
} = this[
|
|
146
|
+
} = this[kElements];
|
|
147
147
|
|
|
148
148
|
if (startActivities.length > 1) {
|
|
149
149
|
for (const a of startActivities) a.shake();
|
|
@@ -151,11 +151,11 @@ proto.resume = function resume() {
|
|
|
151
151
|
|
|
152
152
|
postponed.splice(0);
|
|
153
153
|
detachedActivities.splice(0);
|
|
154
|
-
this[
|
|
154
|
+
this[kActivityQ].consume(this[kMessageHandlers].onChildMessage, {
|
|
155
155
|
prefetch: 1000,
|
|
156
156
|
consumerTag: `_process-activity-${this.executionId}`
|
|
157
157
|
});
|
|
158
|
-
if (this[
|
|
158
|
+
if (this[kCompleted]) return;
|
|
159
159
|
|
|
160
160
|
switch (this.status) {
|
|
161
161
|
case 'init':
|
|
@@ -181,9 +181,9 @@ proto.resume = function resume() {
|
|
|
181
181
|
proto.recover = function recover(state) {
|
|
182
182
|
if (!state) return this;
|
|
183
183
|
this.executionId = state.executionId;
|
|
184
|
-
this[
|
|
185
|
-
this[
|
|
186
|
-
this[
|
|
184
|
+
this[kStopped] = state.stopped;
|
|
185
|
+
this[kCompleted] = state.completed;
|
|
186
|
+
this[kStatus] = state.status;
|
|
187
187
|
|
|
188
188
|
this._debug(`recover process execution at ${this.status}`);
|
|
189
189
|
|
|
@@ -236,7 +236,7 @@ proto.shake = function shake(fromId) {
|
|
|
236
236
|
this._activate();
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
const toShake = fromId ? [this.getActivityById(fromId)].filter(Boolean) : this[
|
|
239
|
+
const toShake = fromId ? [this.getActivityById(fromId)].filter(Boolean) : this[kElements].startActivities;
|
|
240
240
|
const result = {};
|
|
241
241
|
this.broker.subscribeTmp('event', '*.shake.*', (routingKey, {
|
|
242
242
|
content
|
|
@@ -278,7 +278,7 @@ proto.stop = function stop() {
|
|
|
278
278
|
};
|
|
279
279
|
|
|
280
280
|
proto.getPostponed = function getPostponed(filterFn) {
|
|
281
|
-
return this[
|
|
281
|
+
return this[kElements].postponed.slice().reduce((result, msg) => {
|
|
282
282
|
const api = this._getChildApi(msg);
|
|
283
283
|
|
|
284
284
|
if (api) {
|
|
@@ -291,8 +291,8 @@ proto.getPostponed = function getPostponed(filterFn) {
|
|
|
291
291
|
};
|
|
292
292
|
|
|
293
293
|
proto.discard = function discard() {
|
|
294
|
-
this[
|
|
295
|
-
return this[
|
|
294
|
+
this[kStatus] = 'discard';
|
|
295
|
+
return this[kActivityQ].queueMessage({
|
|
296
296
|
routingKey: 'execution.discard'
|
|
297
297
|
}, {
|
|
298
298
|
id: this.id,
|
|
@@ -305,40 +305,47 @@ proto.discard = function discard() {
|
|
|
305
305
|
|
|
306
306
|
proto.getState = function getState() {
|
|
307
307
|
const {
|
|
308
|
+
children,
|
|
308
309
|
flows,
|
|
309
310
|
outboundMessageFlows,
|
|
310
311
|
associations
|
|
311
|
-
} = this[
|
|
312
|
+
} = this[kElements];
|
|
312
313
|
return {
|
|
313
314
|
executionId: this.executionId,
|
|
314
|
-
stopped: this[
|
|
315
|
-
completed: this[
|
|
315
|
+
stopped: this[kStopped],
|
|
316
|
+
completed: this[kCompleted],
|
|
316
317
|
status: this.status,
|
|
317
|
-
children:
|
|
318
|
+
children: children.reduce((result, activity) => {
|
|
318
319
|
if (activity.placeholder) return result;
|
|
319
320
|
result.push(activity.getState());
|
|
320
321
|
return result;
|
|
321
322
|
}, []),
|
|
322
|
-
flows
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
...(flows.length && {
|
|
324
|
+
flows: flows.map(f => f.getState())
|
|
325
|
+
}),
|
|
326
|
+
...(outboundMessageFlows.length && {
|
|
327
|
+
messageFlows: outboundMessageFlows.length && outboundMessageFlows.map(f => f.getState())
|
|
328
|
+
}),
|
|
329
|
+
...(associations.length && {
|
|
330
|
+
associations: associations.map(f => f.getState())
|
|
331
|
+
})
|
|
325
332
|
};
|
|
326
333
|
};
|
|
327
334
|
|
|
328
335
|
proto.getActivities = function getActivities() {
|
|
329
|
-
return this[
|
|
336
|
+
return this[kElements].children.slice();
|
|
330
337
|
};
|
|
331
338
|
|
|
332
339
|
proto.getActivityById = function getActivityById(activityId) {
|
|
333
|
-
return this[
|
|
340
|
+
return this[kElements].children.find(child => child.id === activityId);
|
|
334
341
|
};
|
|
335
342
|
|
|
336
343
|
proto.getSequenceFlows = function getSequenceFlows() {
|
|
337
|
-
return this[
|
|
344
|
+
return this[kElements].flows.slice();
|
|
338
345
|
};
|
|
339
346
|
|
|
340
347
|
proto.getApi = function getApi(message) {
|
|
341
|
-
if (!message) return (0, _Api.ProcessApi)(this.broker, this[
|
|
348
|
+
if (!message) return (0, _Api.ProcessApi)(this.broker, this[kExecuteMessage]);
|
|
342
349
|
const content = message.content;
|
|
343
350
|
|
|
344
351
|
if (content.executionId !== this.executionId) {
|
|
@@ -346,7 +353,7 @@ proto.getApi = function getApi(message) {
|
|
|
346
353
|
}
|
|
347
354
|
|
|
348
355
|
const api = (0, _Api.ProcessApi)(this.broker, message);
|
|
349
|
-
const postponed = this[
|
|
356
|
+
const postponed = this[kElements].postponed;
|
|
350
357
|
const self = this;
|
|
351
358
|
|
|
352
359
|
api.getExecuting = function getExecuting() {
|
|
@@ -362,12 +369,12 @@ proto.getApi = function getApi(message) {
|
|
|
362
369
|
};
|
|
363
370
|
|
|
364
371
|
proto._start = function start() {
|
|
365
|
-
if (this[
|
|
372
|
+
if (this[kElements].children.length === 0) {
|
|
366
373
|
return this._complete('completed');
|
|
367
374
|
}
|
|
368
375
|
|
|
369
|
-
this[
|
|
370
|
-
const executeContent = { ...this[
|
|
376
|
+
this[kStatus] = 'start';
|
|
377
|
+
const executeContent = { ...this[kExecuteMessage].content,
|
|
371
378
|
state: this.status
|
|
372
379
|
};
|
|
373
380
|
this.broker.publish(this._exchangeName, 'execute.start', (0, _messageHelper.cloneContent)(executeContent));
|
|
@@ -375,7 +382,7 @@ proto._start = function start() {
|
|
|
375
382
|
startActivities,
|
|
376
383
|
postponed,
|
|
377
384
|
detachedActivities
|
|
378
|
-
} = this[
|
|
385
|
+
} = this[kElements];
|
|
379
386
|
|
|
380
387
|
if (startActivities.length > 1) {
|
|
381
388
|
for (const a of startActivities) a.shake();
|
|
@@ -387,7 +394,7 @@ proto._start = function start() {
|
|
|
387
394
|
|
|
388
395
|
postponed.splice(0);
|
|
389
396
|
detachedActivities.splice(0);
|
|
390
|
-
this[
|
|
397
|
+
this[kActivityQ].assertConsumer(this[kMessageHandlers].onChildMessage, {
|
|
391
398
|
prefetch: 1000,
|
|
392
399
|
consumerTag: `_process-activity-${this.executionId}`
|
|
393
400
|
});
|
|
@@ -398,7 +405,7 @@ proto._activate = function activate() {
|
|
|
398
405
|
onApiMessage,
|
|
399
406
|
onMessageFlowEvent,
|
|
400
407
|
onActivityEvent
|
|
401
|
-
} = this[
|
|
408
|
+
} = this[kMessageHandlers];
|
|
402
409
|
this.broker.subscribeTmp('api', '#', onApiMessage, {
|
|
403
410
|
noAck: true,
|
|
404
411
|
consumerTag: `_process-api-consumer-${this.executionId}`,
|
|
@@ -411,7 +418,7 @@ proto._activate = function activate() {
|
|
|
411
418
|
startActivities,
|
|
412
419
|
triggeredByEvent,
|
|
413
420
|
children
|
|
414
|
-
} = this[
|
|
421
|
+
} = this[kElements];
|
|
415
422
|
|
|
416
423
|
for (const flow of outboundMessageFlows) {
|
|
417
424
|
flow.activate();
|
|
@@ -453,7 +460,7 @@ proto._activate = function activate() {
|
|
|
453
460
|
if (activity.triggeredByEvent) triggeredByEvent.push(activity);
|
|
454
461
|
}
|
|
455
462
|
|
|
456
|
-
this[
|
|
463
|
+
this[kActivated] = true;
|
|
457
464
|
};
|
|
458
465
|
|
|
459
466
|
proto._deactivate = function deactivate() {
|
|
@@ -466,7 +473,7 @@ proto._deactivate = function deactivate() {
|
|
|
466
473
|
flows,
|
|
467
474
|
associations,
|
|
468
475
|
outboundMessageFlows
|
|
469
|
-
} = this[
|
|
476
|
+
} = this[kElements];
|
|
470
477
|
|
|
471
478
|
for (const activity of children) {
|
|
472
479
|
if (activity.placeholder) continue;
|
|
@@ -487,7 +494,7 @@ proto._deactivate = function deactivate() {
|
|
|
487
494
|
flow.broker.cancel('_process-message-consumer');
|
|
488
495
|
}
|
|
489
496
|
|
|
490
|
-
this[
|
|
497
|
+
this[kActivated] = false;
|
|
491
498
|
};
|
|
492
499
|
|
|
493
500
|
proto._onDelegateEvent = function onDelegateEvent(message) {
|
|
@@ -501,7 +508,7 @@ proto._onDelegateEvent = function onDelegateEvent(message) {
|
|
|
501
508
|
this._debug(`delegate ${eventType} anonymous event`);
|
|
502
509
|
}
|
|
503
510
|
|
|
504
|
-
for (const activity of this[
|
|
511
|
+
for (const activity of this[kElements].triggeredByEvent) {
|
|
505
512
|
if (activity.getStartActivities({
|
|
506
513
|
referenceId: content.message && content.message.id,
|
|
507
514
|
referenceType: eventType
|
|
@@ -550,7 +557,7 @@ proto._onActivityEvent = function onActivityEvent(routingKey, message) {
|
|
|
550
557
|
|
|
551
558
|
switch (routingKey) {
|
|
552
559
|
case 'process.terminate':
|
|
553
|
-
return this[
|
|
560
|
+
return this[kActivityQ].queueMessage({
|
|
554
561
|
routingKey: 'execution.terminate'
|
|
555
562
|
}, (0, _messageHelper.cloneContent)(content), {
|
|
556
563
|
type: 'terminate',
|
|
@@ -561,7 +568,7 @@ proto._onActivityEvent = function onActivityEvent(routingKey, message) {
|
|
|
561
568
|
return;
|
|
562
569
|
}
|
|
563
570
|
|
|
564
|
-
this[
|
|
571
|
+
this[kActivityQ].queueMessage(message.fields, (0, _messageHelper.cloneContent)(content), {
|
|
565
572
|
persistent: true,
|
|
566
573
|
...message.properties
|
|
567
574
|
});
|
|
@@ -595,7 +602,7 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
|
|
|
595
602
|
switch (routingKey) {
|
|
596
603
|
case 'activity.detach':
|
|
597
604
|
{
|
|
598
|
-
this[
|
|
605
|
+
this[kElements].detachedActivities.push((0, _messageHelper.cloneMessage)(message));
|
|
599
606
|
break;
|
|
600
607
|
}
|
|
601
608
|
|
|
@@ -603,7 +610,7 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
|
|
|
603
610
|
case 'activity.compensation.start':
|
|
604
611
|
case 'activity.enter':
|
|
605
612
|
{
|
|
606
|
-
this[
|
|
613
|
+
this[kStatus] = 'executing';
|
|
607
614
|
if (!content.inbound) break;
|
|
608
615
|
|
|
609
616
|
for (const inbound of content.inbound) {
|
|
@@ -617,10 +624,9 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
|
|
|
617
624
|
break;
|
|
618
625
|
}
|
|
619
626
|
|
|
620
|
-
case 'flow.error':
|
|
621
627
|
case 'activity.error':
|
|
622
628
|
{
|
|
623
|
-
const eventCaughtBy = this[
|
|
629
|
+
const eventCaughtBy = this[kElements].postponed.find(msg => {
|
|
624
630
|
if (msg.fields.routingKey !== 'activity.catch') return;
|
|
625
631
|
return msg.content.source && msg.content.source.executionId === content.executionId;
|
|
626
632
|
});
|
|
@@ -640,14 +646,14 @@ proto._stateChangeMessage = function stateChangeMessage(message, postponeMessage
|
|
|
640
646
|
const previousMsg = this._popPostponed(message.content);
|
|
641
647
|
|
|
642
648
|
if (previousMsg) previousMsg.ack();
|
|
643
|
-
if (postponeMessage) this[
|
|
649
|
+
if (postponeMessage) this[kElements].postponed.push(message);
|
|
644
650
|
};
|
|
645
651
|
|
|
646
652
|
proto._popPostponed = function popPostponed(byContent) {
|
|
647
653
|
const {
|
|
648
654
|
postponed,
|
|
649
655
|
detachedActivities
|
|
650
|
-
} = this[
|
|
656
|
+
} = this[kElements];
|
|
651
657
|
const postponedIdx = postponed.findIndex(msg => {
|
|
652
658
|
if (msg.content.isSequenceFlow) return msg.content.sequenceId === byContent.sequenceId;
|
|
653
659
|
return msg.content.executionId === byContent.executionId;
|
|
@@ -676,7 +682,7 @@ proto._onChildCompleted = function onChildCompleted(message) {
|
|
|
676
682
|
postponed,
|
|
677
683
|
detachedActivities,
|
|
678
684
|
startActivities
|
|
679
|
-
} = this[
|
|
685
|
+
} = this[kElements];
|
|
680
686
|
const postponedCount = postponed.length;
|
|
681
687
|
|
|
682
688
|
if (!postponedCount) {
|
|
@@ -695,7 +701,7 @@ proto._onChildCompleted = function onChildCompleted(message) {
|
|
|
695
701
|
}
|
|
696
702
|
|
|
697
703
|
if (isEnd && startActivities.length) {
|
|
698
|
-
const startSequences = this[
|
|
704
|
+
const startSequences = this[kElements].startSequences;
|
|
699
705
|
|
|
700
706
|
for (const msg of postponed) {
|
|
701
707
|
const postponedId = msg.content.id;
|
|
@@ -713,7 +719,6 @@ proto._onChildCompleted = function onChildCompleted(message) {
|
|
|
713
719
|
};
|
|
714
720
|
|
|
715
721
|
proto._stopExecution = function stopExecution(message) {
|
|
716
|
-
if (this[stoppedSymbol]) return;
|
|
717
722
|
const postponedCount = this.postponedCount;
|
|
718
723
|
|
|
719
724
|
this._debug(`stop process execution (stop child executions ${postponedCount})`);
|
|
@@ -724,8 +729,8 @@ proto._stopExecution = function stopExecution(message) {
|
|
|
724
729
|
|
|
725
730
|
this._deactivate();
|
|
726
731
|
|
|
727
|
-
this[
|
|
728
|
-
return this.broker.publish(this._exchangeName, `execution.stopped.${this.executionId}`, { ...this[
|
|
732
|
+
this[kStopped] = true;
|
|
733
|
+
return this.broker.publish(this._exchangeName, `execution.stopped.${this.executionId}`, { ...this[kExecuteMessage].content,
|
|
729
734
|
...(message && message.content)
|
|
730
735
|
}, {
|
|
731
736
|
type: 'stopped',
|
|
@@ -736,7 +741,7 @@ proto._stopExecution = function stopExecution(message) {
|
|
|
736
741
|
proto._onDiscard = function onDiscard() {
|
|
737
742
|
this._deactivate();
|
|
738
743
|
|
|
739
|
-
const running = this[
|
|
744
|
+
const running = this[kElements].postponed.splice(0);
|
|
740
745
|
|
|
741
746
|
this._debug(`discard process execution (discard child executions ${running.length})`);
|
|
742
747
|
|
|
@@ -744,7 +749,7 @@ proto._onDiscard = function onDiscard() {
|
|
|
744
749
|
|
|
745
750
|
for (const msg of running) this._getChildApi(msg).discard();
|
|
746
751
|
|
|
747
|
-
this[
|
|
752
|
+
this[kActivityQ].purge();
|
|
748
753
|
return this._complete('discard');
|
|
749
754
|
};
|
|
750
755
|
|
|
@@ -753,9 +758,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
753
758
|
const broker = this.broker;
|
|
754
759
|
|
|
755
760
|
if (message.properties.delegate) {
|
|
756
|
-
const
|
|
757
|
-
correlationId
|
|
758
|
-
} = message.properties || (0, _shared.getUniqueId)(executionId);
|
|
761
|
+
const correlationId = message.properties.correlationId || (0, _shared.getUniqueId)(executionId);
|
|
759
762
|
|
|
760
763
|
this._debug(`delegate api ${routingKey} message to children, with correlationId <${correlationId}>`);
|
|
761
764
|
|
|
@@ -771,7 +774,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
771
774
|
noAck: true
|
|
772
775
|
});
|
|
773
776
|
|
|
774
|
-
for (const child of this[
|
|
777
|
+
for (const child of this[kElements].children) {
|
|
775
778
|
if (child.placeholder) continue;
|
|
776
779
|
child.broker.publish('api', routingKey, (0, _messageHelper.cloneContent)(message.content), message.properties);
|
|
777
780
|
if (consumed) break;
|
|
@@ -793,7 +796,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
793
796
|
return this.discard(message);
|
|
794
797
|
|
|
795
798
|
case 'stop':
|
|
796
|
-
this[
|
|
799
|
+
this[kActivityQ].queueMessage({
|
|
797
800
|
routingKey: 'execution.stop'
|
|
798
801
|
}, (0, _messageHelper.cloneContent)(message.content), {
|
|
799
802
|
persistent: false
|
|
@@ -807,11 +810,11 @@ proto._complete = function complete(completionType, content) {
|
|
|
807
810
|
|
|
808
811
|
this._debug(`process execution ${completionType}`);
|
|
809
812
|
|
|
810
|
-
this[
|
|
811
|
-
if (this.status !== 'terminated') this[
|
|
813
|
+
this[kCompleted] = true;
|
|
814
|
+
if (this.status !== 'terminated') this[kStatus] = completionType;
|
|
812
815
|
const broker = this.broker;
|
|
813
|
-
this[
|
|
814
|
-
return broker.publish(this._exchangeName, `execution.${completionType}.${this.executionId}`, (0, _messageHelper.cloneContent)(this[
|
|
816
|
+
this[kActivityQ].delete();
|
|
817
|
+
return broker.publish(this._exchangeName, `execution.${completionType}.${this.executionId}`, (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
|
|
815
818
|
output: { ...this.environment.output
|
|
816
819
|
},
|
|
817
820
|
...content,
|
|
@@ -823,11 +826,11 @@ proto._complete = function complete(completionType, content) {
|
|
|
823
826
|
};
|
|
824
827
|
|
|
825
828
|
proto._terminate = function terminate(message) {
|
|
826
|
-
this[
|
|
829
|
+
this[kStatus] = 'terminated';
|
|
827
830
|
|
|
828
831
|
this._debug('terminating process execution');
|
|
829
832
|
|
|
830
|
-
const running = this[
|
|
833
|
+
const running = this[kElements].postponed.splice(0);
|
|
831
834
|
|
|
832
835
|
for (const flow of this.getSequenceFlows()) flow.stop();
|
|
833
836
|
|
|
@@ -844,19 +847,19 @@ proto._terminate = function terminate(message) {
|
|
|
844
847
|
msg.ack();
|
|
845
848
|
}
|
|
846
849
|
|
|
847
|
-
this[
|
|
850
|
+
this[kActivityQ].purge();
|
|
848
851
|
};
|
|
849
852
|
|
|
850
853
|
proto._getFlowById = function getFlowById(flowId) {
|
|
851
|
-
return this[
|
|
854
|
+
return this[kElements].flows.find(f => f.id === flowId);
|
|
852
855
|
};
|
|
853
856
|
|
|
854
857
|
proto._getAssociationById = function getAssociationById(associationId) {
|
|
855
|
-
return this[
|
|
858
|
+
return this[kElements].associations.find(a => a.id === associationId);
|
|
856
859
|
};
|
|
857
860
|
|
|
858
861
|
proto._getMessageFlowById = function getMessageFlowById(flowId) {
|
|
859
|
-
return this[
|
|
862
|
+
return this[kElements].outboundMessageFlows.find(f => f.id === flowId);
|
|
860
863
|
};
|
|
861
864
|
|
|
862
865
|
proto._getChildById = function getChildById(childId) {
|
|
@@ -883,9 +886,9 @@ proto._getChildApi = function getChildApi(message) {
|
|
|
883
886
|
proto._onShookEnd = function onShookEnd(message) {
|
|
884
887
|
const routingKey = message.fields.routingKey;
|
|
885
888
|
if (routingKey !== 'activity.shake.end') return;
|
|
886
|
-
this[
|
|
889
|
+
this[kElements].startSequences[message.content.id] = (0, _messageHelper.cloneMessage)(message);
|
|
887
890
|
};
|
|
888
891
|
|
|
889
892
|
proto._debug = function debugMessage(logMessage) {
|
|
890
|
-
this[
|
|
893
|
+
this[kParent].logger.debug(`<${this.executionId} (${this.id})> ${logMessage}`);
|
|
891
894
|
};
|
|
@@ -12,10 +12,10 @@ var _messageHelper = require("../messageHelper");
|
|
|
12
12
|
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
15
|
+
const kCompleted = Symbol.for('completed');
|
|
16
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
17
|
+
const kReferenceElement = Symbol.for('referenceElement');
|
|
18
|
+
const kReferenceInfo = Symbol.for('referenceInfo');
|
|
19
19
|
|
|
20
20
|
function ReceiveTask(activityDef, context) {
|
|
21
21
|
const task = new _Activity.default(ReceiveTaskBehaviour, activityDef, context);
|
|
@@ -45,7 +45,7 @@ function ReceiveTaskBehaviour(activity) {
|
|
|
45
45
|
this.loopCharacteristics = behaviour.loopCharacteristics && new behaviour.loopCharacteristics.Behaviour(activity, behaviour.loopCharacteristics);
|
|
46
46
|
this.activity = activity;
|
|
47
47
|
this.broker = activity.broker;
|
|
48
|
-
this[
|
|
48
|
+
this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
ReceiveTaskBehaviour.prototype.execute = function execute(executeMessage) {
|
|
@@ -64,14 +64,14 @@ function ReceiveTaskExecution(parent) {
|
|
|
64
64
|
this.reference = reference;
|
|
65
65
|
this.broker = broker;
|
|
66
66
|
this.loopCharacteristics = loopCharacteristics;
|
|
67
|
-
this.referenceElement = parent[
|
|
68
|
-
this[
|
|
67
|
+
this.referenceElement = parent[kReferenceElement];
|
|
68
|
+
this[kCompleted] = false;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const proto = ReceiveTaskExecution.prototype;
|
|
72
72
|
|
|
73
73
|
proto.execute = function execute(executeMessage) {
|
|
74
|
-
this[
|
|
74
|
+
this[kExecuteMessage] = executeMessage;
|
|
75
75
|
const executeContent = executeMessage.content;
|
|
76
76
|
const {
|
|
77
77
|
executionId,
|
|
@@ -79,7 +79,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
79
79
|
} = executeContent;
|
|
80
80
|
this.executionId = executionId;
|
|
81
81
|
|
|
82
|
-
const info = this[
|
|
82
|
+
const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
|
|
83
83
|
|
|
84
84
|
if (isRootScope) {
|
|
85
85
|
this._setupMessageHandling(executionId);
|
|
@@ -96,7 +96,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
96
96
|
noAck: true,
|
|
97
97
|
consumerTag: `_onmessage-${executionId}`
|
|
98
98
|
});
|
|
99
|
-
if (this[
|
|
99
|
+
if (this[kCompleted]) return;
|
|
100
100
|
broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
|
|
101
101
|
noAck: true,
|
|
102
102
|
consumerTag: `_api-${executionId}`,
|
|
@@ -120,7 +120,7 @@ proto._onCatchMessage = function onCatchMessage(routingKey, message) {
|
|
|
120
120
|
const {
|
|
121
121
|
message: referenceMessage,
|
|
122
122
|
description
|
|
123
|
-
} = this[
|
|
123
|
+
} = this[kReferenceInfo];
|
|
124
124
|
|
|
125
125
|
if (!referenceMessage.id && signalId || signalExecutionId) {
|
|
126
126
|
if (this.loopCharacteristics && signalExecutionId !== this.executionId) return;
|
|
@@ -136,7 +136,7 @@ proto._onCatchMessage = function onCatchMessage(routingKey, message) {
|
|
|
136
136
|
correlationId
|
|
137
137
|
} = message.properties;
|
|
138
138
|
const broker = this.broker;
|
|
139
|
-
const executeContent = this[
|
|
139
|
+
const executeContent = this[kExecuteMessage].content;
|
|
140
140
|
broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
141
141
|
message: { ...message.content.message
|
|
142
142
|
}
|
|
@@ -173,11 +173,11 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
173
173
|
|
|
174
174
|
case 'discard':
|
|
175
175
|
{
|
|
176
|
-
this[
|
|
176
|
+
this[kCompleted] = true;
|
|
177
177
|
|
|
178
178
|
this._stop();
|
|
179
179
|
|
|
180
|
-
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[
|
|
180
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content), {
|
|
181
181
|
correlationId
|
|
182
182
|
});
|
|
183
183
|
}
|
|
@@ -190,11 +190,11 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
190
190
|
};
|
|
191
191
|
|
|
192
192
|
proto._complete = function complete(output, options) {
|
|
193
|
-
this[
|
|
193
|
+
this[kCompleted] = true;
|
|
194
194
|
|
|
195
195
|
this._stop();
|
|
196
196
|
|
|
197
|
-
return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(this[
|
|
197
|
+
return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
|
|
198
198
|
output
|
|
199
199
|
}), options);
|
|
200
200
|
};
|