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
|
@@ -9,11 +9,11 @@ var _Api = require("../Api");
|
|
|
9
9
|
|
|
10
10
|
var _messageHelper = require("../messageHelper");
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
12
|
+
const kCompleted = Symbol.for('completed');
|
|
13
|
+
const kExecuteQ = Symbol.for('executeQ');
|
|
14
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
15
|
+
const kMessageHandlers = Symbol.for('messageHandlers');
|
|
16
|
+
const kPostponed = Symbol.for('postponed');
|
|
17
17
|
var _default = ActivityExecution;
|
|
18
18
|
exports.default = _default;
|
|
19
19
|
|
|
@@ -22,13 +22,13 @@ function ActivityExecution(activity, context) {
|
|
|
22
22
|
this.context = context;
|
|
23
23
|
this.id = activity.id;
|
|
24
24
|
this.broker = activity.broker;
|
|
25
|
-
this[
|
|
26
|
-
this[
|
|
27
|
-
this[
|
|
25
|
+
this[kPostponed] = [];
|
|
26
|
+
this[kCompleted] = false;
|
|
27
|
+
this[kExecuteQ] = this.broker.assertQueue('execute-q', {
|
|
28
28
|
durable: true,
|
|
29
29
|
autoDelete: false
|
|
30
30
|
});
|
|
31
|
-
this[
|
|
31
|
+
this[kMessageHandlers] = {
|
|
32
32
|
onParentApiMessage: this._onParentApiMessage.bind(this),
|
|
33
33
|
onExecuteMessage: this._onExecuteMessage.bind(this)
|
|
34
34
|
};
|
|
@@ -39,7 +39,7 @@ Object.defineProperty(proto, 'completed', {
|
|
|
39
39
|
enumerable: true,
|
|
40
40
|
|
|
41
41
|
get() {
|
|
42
|
-
return this[
|
|
42
|
+
return this[kCompleted];
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
});
|
|
@@ -49,14 +49,14 @@ proto.execute = function execute(executeMessage) {
|
|
|
49
49
|
const executionId = executeMessage.content && executeMessage.content.executionId;
|
|
50
50
|
if (!executionId) throw new Error('Execution requires execution id');
|
|
51
51
|
this.executionId = executionId;
|
|
52
|
-
const initMessage = this[
|
|
52
|
+
const initMessage = this[kExecuteMessage] = (0, _messageHelper.cloneMessage)(executeMessage, {
|
|
53
53
|
executionId,
|
|
54
54
|
state: 'start',
|
|
55
55
|
isRootScope: true
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
if (executeMessage.fields.redelivered) {
|
|
59
|
-
this[
|
|
59
|
+
this[kPostponed].splice(0);
|
|
60
60
|
|
|
61
61
|
this._debug('resume execution');
|
|
62
62
|
|
|
@@ -75,7 +75,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
proto.activate = function activate() {
|
|
78
|
-
if (this[
|
|
78
|
+
if (this[kCompleted]) return;
|
|
79
79
|
const broker = this.broker;
|
|
80
80
|
const batchSize = this.activity.environment.settings.batchSize || 50;
|
|
81
81
|
broker.bindQueue('execute-q', 'execution', 'execute.#', {
|
|
@@ -84,14 +84,14 @@ proto.activate = function activate() {
|
|
|
84
84
|
const {
|
|
85
85
|
onExecuteMessage,
|
|
86
86
|
onParentApiMessage
|
|
87
|
-
} = this[
|
|
88
|
-
this[
|
|
87
|
+
} = this[kMessageHandlers];
|
|
88
|
+
this[kExecuteQ].assertConsumer(onExecuteMessage, {
|
|
89
89
|
exclusive: true,
|
|
90
90
|
prefetch: batchSize * 2,
|
|
91
91
|
priority: 100,
|
|
92
92
|
consumerTag: '_activity-execute'
|
|
93
93
|
});
|
|
94
|
-
if (this[
|
|
94
|
+
if (this[kCompleted]) return this.deactivate();
|
|
95
95
|
broker.subscribeTmp('api', `activity.*.${this.executionId}`, onParentApiMessage, {
|
|
96
96
|
noAck: true,
|
|
97
97
|
consumerTag: '_activity-api-execution',
|
|
@@ -107,15 +107,15 @@ proto.deactivate = function deactivate() {
|
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
proto.discard = function discard() {
|
|
110
|
-
if (this[
|
|
111
|
-
const initMessage = this[
|
|
110
|
+
if (this[kCompleted]) return;
|
|
111
|
+
const initMessage = this[kExecuteMessage];
|
|
112
112
|
if (!initMessage) return this.activity.logger.warn(`<${this.id}> is not executing`);
|
|
113
113
|
this.getApi(initMessage).discard();
|
|
114
114
|
};
|
|
115
115
|
|
|
116
116
|
proto.getApi = function getApi(apiMessage) {
|
|
117
117
|
const self = this;
|
|
118
|
-
if (!apiMessage) apiMessage = this[
|
|
118
|
+
if (!apiMessage) apiMessage = this[kExecuteMessage];
|
|
119
119
|
|
|
120
120
|
if (self.source.getApi) {
|
|
121
121
|
const sourceApi = self.source.getApi(apiMessage);
|
|
@@ -125,7 +125,7 @@ proto.getApi = function getApi(apiMessage) {
|
|
|
125
125
|
const api = (0, _Api.ActivityApi)(self.broker, apiMessage);
|
|
126
126
|
|
|
127
127
|
api.getExecuting = function getExecuting() {
|
|
128
|
-
return self[
|
|
128
|
+
return self[kPostponed].reduce((result, msg) => {
|
|
129
129
|
if (msg.content.executionId === apiMessage.content.executionId) return result;
|
|
130
130
|
result.push(self.getApi(msg));
|
|
131
131
|
return result;
|
|
@@ -141,7 +141,7 @@ proto.passthrough = function passthrough(executeMessage) {
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
proto.getPostponed = function getPostponed() {
|
|
144
|
-
let apis = this[
|
|
144
|
+
let apis = this[kPostponed].map(msg => this.getApi(msg));
|
|
145
145
|
if (!this.activity.isSubProcess || !this.source) return apis;
|
|
146
146
|
apis = apis.concat(this.source.getPostponed());
|
|
147
147
|
return apis;
|
|
@@ -149,7 +149,7 @@ proto.getPostponed = function getPostponed() {
|
|
|
149
149
|
|
|
150
150
|
proto.getState = function getState() {
|
|
151
151
|
const result = {
|
|
152
|
-
completed: this[
|
|
152
|
+
completed: this[kCompleted]
|
|
153
153
|
};
|
|
154
154
|
const source = this.source;
|
|
155
155
|
if (!source || !source.getState) return result;
|
|
@@ -159,9 +159,9 @@ proto.getState = function getState() {
|
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
proto.recover = function recover(state) {
|
|
162
|
-
this[
|
|
162
|
+
this[kPostponed].splice(0);
|
|
163
163
|
if (!state) return this;
|
|
164
|
-
if ('completed' in state) this[
|
|
164
|
+
if ('completed' in state) this[kCompleted] = state.completed;
|
|
165
165
|
const source = this.source = new this.activity.Behaviour(this.activity, this.context);
|
|
166
166
|
|
|
167
167
|
if (source.recover) {
|
|
@@ -172,7 +172,7 @@ proto.recover = function recover(state) {
|
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
proto.stop = function stop() {
|
|
175
|
-
const executeMessage = this[
|
|
175
|
+
const executeMessage = this[kExecuteMessage];
|
|
176
176
|
if (!executeMessage) return;
|
|
177
177
|
this.getApi(executeMessage).stop();
|
|
178
178
|
};
|
|
@@ -199,7 +199,7 @@ proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
|
|
|
199
199
|
switch (routingKey) {
|
|
200
200
|
case 'execute.resume.execution':
|
|
201
201
|
{
|
|
202
|
-
if (!this[
|
|
202
|
+
if (!this[kPostponed].length) return this.broker.publish('execution', 'execute.start', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
|
|
203
203
|
break;
|
|
204
204
|
}
|
|
205
205
|
|
|
@@ -253,7 +253,7 @@ proto._onStateChangeMessage = function onStateChangeMessage(message) {
|
|
|
253
253
|
ignoreIfExecuting,
|
|
254
254
|
executionId
|
|
255
255
|
} = message.content;
|
|
256
|
-
const postponed = this[
|
|
256
|
+
const postponed = this[kPostponed];
|
|
257
257
|
const idx = postponed.findIndex(msg => msg.content.executionId === executionId);
|
|
258
258
|
let previousMsg;
|
|
259
259
|
|
|
@@ -276,7 +276,7 @@ proto._onExecutionCompleted = function onExecutionCompleted(message) {
|
|
|
276
276
|
const postponedMsg = this._ackPostponed(message);
|
|
277
277
|
|
|
278
278
|
if (!postponedMsg) return;
|
|
279
|
-
const postponed = this[
|
|
279
|
+
const postponed = this[kPostponed];
|
|
280
280
|
const {
|
|
281
281
|
executionId,
|
|
282
282
|
keep,
|
|
@@ -297,7 +297,7 @@ proto._onExecutionCompleted = function onExecutionCompleted(message) {
|
|
|
297
297
|
|
|
298
298
|
this._debug('completed execution', executionId);
|
|
299
299
|
|
|
300
|
-
this[
|
|
300
|
+
this[kCompleted] = true;
|
|
301
301
|
message.ack(true);
|
|
302
302
|
this.deactivate();
|
|
303
303
|
const subApis = this.getPostponed();
|
|
@@ -318,7 +318,7 @@ proto._onExecutionDiscarded = function onExecutionDiscarded(message) {
|
|
|
318
318
|
error
|
|
319
319
|
} = message.content;
|
|
320
320
|
if (!isRootScope && !postponedMsg) return;
|
|
321
|
-
const postponed = this[
|
|
321
|
+
const postponed = this[kPostponed];
|
|
322
322
|
const correlationId = message.properties.correlationId;
|
|
323
323
|
|
|
324
324
|
if (!error && !isRootScope) {
|
|
@@ -350,7 +350,7 @@ proto._onExecutionDiscarded = function onExecutionDiscarded(message) {
|
|
|
350
350
|
};
|
|
351
351
|
|
|
352
352
|
proto._publishExecutionCompleted = function publishExecutionCompleted(completionType, completeContent, correlationId) {
|
|
353
|
-
this[
|
|
353
|
+
this[kCompleted] = true;
|
|
354
354
|
this.broker.publish('execution', `execution.${completionType}`, { ...completeContent,
|
|
355
355
|
state: completionType
|
|
356
356
|
}, {
|
|
@@ -363,7 +363,7 @@ proto._ackPostponed = function ackPostponed(completeMessage) {
|
|
|
363
363
|
const {
|
|
364
364
|
executionId: eid
|
|
365
365
|
} = completeMessage.content;
|
|
366
|
-
const postponed = this[
|
|
366
|
+
const postponed = this[kPostponed];
|
|
367
367
|
const idx = postponed.findIndex(({
|
|
368
368
|
content: c
|
|
369
369
|
}) => c.executionId === eid);
|
|
@@ -376,16 +376,16 @@ proto._ackPostponed = function ackPostponed(completeMessage) {
|
|
|
376
376
|
proto._onParentApiMessage = function onParentApiMessage(routingKey, message) {
|
|
377
377
|
switch (message.properties.type) {
|
|
378
378
|
case 'error':
|
|
379
|
-
return this[
|
|
379
|
+
return this[kExecuteQ].queueMessage({
|
|
380
380
|
routingKey: 'execute.error'
|
|
381
381
|
}, {
|
|
382
382
|
error: message.content.error
|
|
383
383
|
});
|
|
384
384
|
|
|
385
385
|
case 'discard':
|
|
386
|
-
return this[
|
|
386
|
+
return this[kExecuteQ].queueMessage({
|
|
387
387
|
routingKey: 'execute.discard'
|
|
388
|
-
}, (0, _messageHelper.cloneContent)(this[
|
|
388
|
+
}, (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
|
|
389
389
|
|
|
390
390
|
case 'stop':
|
|
391
391
|
{
|
|
@@ -414,9 +414,9 @@ proto._debug = function debug(logMessage, executionId) {
|
|
|
414
414
|
};
|
|
415
415
|
|
|
416
416
|
function getExecuteMessage(message) {
|
|
417
|
-
const result = (0, _messageHelper.cloneMessage)(message, { ...(message.fields.redelivered
|
|
417
|
+
const result = (0, _messageHelper.cloneMessage)(message, { ...(message.fields.redelivered && {
|
|
418
418
|
isRecovered: true
|
|
419
|
-
}
|
|
419
|
+
}),
|
|
420
420
|
ignoreIfExecuting: undefined
|
|
421
421
|
});
|
|
422
422
|
return result;
|
|
@@ -20,14 +20,14 @@ var _messageHelper = require("../messageHelper");
|
|
|
20
20
|
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
23
|
+
const kConsuming = Symbol.for('consuming');
|
|
24
|
+
const kCounters = Symbol.for('counters');
|
|
25
|
+
const kExec = Symbol.for('execution');
|
|
26
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
27
|
+
const kMessageHandlers = Symbol.for('messageHandlers');
|
|
28
|
+
const kStateMessage = Symbol.for('stateMessage');
|
|
29
|
+
const kStatus = Symbol.for('status');
|
|
30
|
+
const kStopped = Symbol.for('stopped');
|
|
31
31
|
var _default = Definition;
|
|
32
32
|
exports.default = _default;
|
|
33
33
|
|
|
@@ -52,16 +52,16 @@ function Definition(context, options) {
|
|
|
52
52
|
this.context = context;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
this[
|
|
55
|
+
this[kCounters] = {
|
|
56
56
|
completed: 0,
|
|
57
57
|
discarded: 0
|
|
58
58
|
};
|
|
59
|
-
this[
|
|
60
|
-
this[
|
|
59
|
+
this[kStopped] = false;
|
|
60
|
+
this[kExec] = {};
|
|
61
61
|
|
|
62
62
|
const onBrokerReturn = this._onBrokerReturnFn.bind(this);
|
|
63
63
|
|
|
64
|
-
this[
|
|
64
|
+
this[kMessageHandlers] = {
|
|
65
65
|
onBrokerReturn,
|
|
66
66
|
onApiMessage: this._onApiMessage.bind(this),
|
|
67
67
|
onRunMessage: this._onRunMessage.bind(this),
|
|
@@ -89,7 +89,7 @@ Object.defineProperty(proto, 'counters', {
|
|
|
89
89
|
enumerable: true,
|
|
90
90
|
|
|
91
91
|
get() {
|
|
92
|
-
return { ...this[
|
|
92
|
+
return { ...this[kCounters]
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -98,7 +98,7 @@ Object.defineProperty(proto, 'execution', {
|
|
|
98
98
|
enumerable: true,
|
|
99
99
|
|
|
100
100
|
get() {
|
|
101
|
-
return this[
|
|
101
|
+
return this[kExec].execution;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
});
|
|
@@ -106,7 +106,7 @@ Object.defineProperty(proto, 'executionId', {
|
|
|
106
106
|
enumerable: true,
|
|
107
107
|
|
|
108
108
|
get() {
|
|
109
|
-
return this[
|
|
109
|
+
return this[kExec].executionId;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
});
|
|
@@ -114,7 +114,7 @@ Object.defineProperty(proto, 'isRunning', {
|
|
|
114
114
|
enumerable: true,
|
|
115
115
|
|
|
116
116
|
get() {
|
|
117
|
-
if (!this[
|
|
117
|
+
if (!this[kConsuming]) return false;
|
|
118
118
|
return !!this.status;
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -123,7 +123,7 @@ Object.defineProperty(proto, 'status', {
|
|
|
123
123
|
enumerable: true,
|
|
124
124
|
|
|
125
125
|
get() {
|
|
126
|
-
return this[
|
|
126
|
+
return this[kStatus];
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
});
|
|
@@ -131,7 +131,7 @@ Object.defineProperty(proto, 'stopped', {
|
|
|
131
131
|
enumerable: true,
|
|
132
132
|
|
|
133
133
|
get() {
|
|
134
|
-
return this[
|
|
134
|
+
return this[kStopped];
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
});
|
|
@@ -149,7 +149,7 @@ proto.run = function run(optionsOrCallback, optionalCallback) {
|
|
|
149
149
|
addConsumerCallbacks(this, callback);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
const exec = this[
|
|
152
|
+
const exec = this[kExec];
|
|
153
153
|
exec.executionId = (0, _shared.getUniqueId)(this.id);
|
|
154
154
|
|
|
155
155
|
const content = this._createMessage({ ...runOptions
|
|
@@ -173,7 +173,7 @@ proto.resume = function resume(callback) {
|
|
|
173
173
|
throw err;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
this[
|
|
176
|
+
this[kStopped] = false;
|
|
177
177
|
if (!this.status) return this;
|
|
178
178
|
|
|
179
179
|
if (callback) {
|
|
@@ -196,13 +196,13 @@ proto.resume = function resume(callback) {
|
|
|
196
196
|
proto.recover = function recover(state) {
|
|
197
197
|
if (this.isRunning) throw new Error('cannot recover running definition');
|
|
198
198
|
if (!state) return this;
|
|
199
|
-
this[
|
|
200
|
-
this[
|
|
201
|
-
const exec = this[
|
|
199
|
+
this[kStopped] = !!state.stopped;
|
|
200
|
+
this[kStatus] = state.status;
|
|
201
|
+
const exec = this[kExec];
|
|
202
202
|
exec.executionId = state.executionId;
|
|
203
203
|
|
|
204
204
|
if (state.counters) {
|
|
205
|
-
this[
|
|
205
|
+
this[kCounters] = { ...this[kCounters],
|
|
206
206
|
...state.counters
|
|
207
207
|
};
|
|
208
208
|
}
|
|
@@ -288,10 +288,10 @@ proto.getProcessById = function getProcessById(processId) {
|
|
|
288
288
|
};
|
|
289
289
|
|
|
290
290
|
proto.getActivityById = function getActivityById(childId) {
|
|
291
|
-
const
|
|
291
|
+
const bps = this.getProcesses();
|
|
292
292
|
|
|
293
|
-
for (const
|
|
294
|
-
const child =
|
|
293
|
+
for (const bp of bps) {
|
|
294
|
+
const child = bp.getActivityById(childId);
|
|
295
295
|
if (child) return child;
|
|
296
296
|
}
|
|
297
297
|
|
|
@@ -311,7 +311,7 @@ proto.getPostponed = function getPostponed(...args) {
|
|
|
311
311
|
proto.getApi = function getApi(message) {
|
|
312
312
|
const execution = this.execution;
|
|
313
313
|
if (execution) return execution.getApi(message);
|
|
314
|
-
message = message || this[
|
|
314
|
+
message = message || this[kStateMessage];
|
|
315
315
|
if (!message) throw new Error('Definition is not running');
|
|
316
316
|
return (0, _Api.DefinitionApi)(this.broker, message);
|
|
317
317
|
};
|
|
@@ -356,12 +356,12 @@ proto.stop = function stop() {
|
|
|
356
356
|
};
|
|
357
357
|
|
|
358
358
|
proto._activateRunConsumers = function activateRunConsumers() {
|
|
359
|
-
this[
|
|
359
|
+
this[kConsuming] = true;
|
|
360
360
|
const broker = this.broker;
|
|
361
361
|
const {
|
|
362
362
|
onApiMessage,
|
|
363
363
|
onRunMessage
|
|
364
|
-
} = this[
|
|
364
|
+
} = this[kMessageHandlers];
|
|
365
365
|
broker.subscribeTmp('api', `definition.*.${this.executionId}`, onApiMessage, {
|
|
366
366
|
noAck: true,
|
|
367
367
|
consumerTag: '_definition-api'
|
|
@@ -377,7 +377,7 @@ proto._deactivateRunConsumers = function deactivateRunConsumers() {
|
|
|
377
377
|
broker.cancel('_definition-api');
|
|
378
378
|
broker.cancel('_definition-run');
|
|
379
379
|
broker.cancel('_definition-execution');
|
|
380
|
-
this[
|
|
380
|
+
this[kConsuming] = false;
|
|
381
381
|
};
|
|
382
382
|
|
|
383
383
|
proto._createMessage = function createMessage(override) {
|
|
@@ -400,14 +400,14 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
400
400
|
return this._onResumeMessage(message);
|
|
401
401
|
}
|
|
402
402
|
|
|
403
|
-
const exec = this[
|
|
404
|
-
this[
|
|
403
|
+
const exec = this[kExec];
|
|
404
|
+
this[kStateMessage] = message;
|
|
405
405
|
|
|
406
406
|
switch (routingKey) {
|
|
407
407
|
case 'run.enter':
|
|
408
408
|
{
|
|
409
409
|
this.logger.debug(`<${this.executionId} (${this.id})> enter`);
|
|
410
|
-
this[
|
|
410
|
+
this[kStatus] = 'entered';
|
|
411
411
|
if (fields.redelivered) break;
|
|
412
412
|
exec.execution = undefined;
|
|
413
413
|
|
|
@@ -419,7 +419,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
419
419
|
case 'run.start':
|
|
420
420
|
{
|
|
421
421
|
this.logger.debug(`<${this.executionId} (${this.id})> start`);
|
|
422
|
-
this[
|
|
422
|
+
this[kStatus] = 'start';
|
|
423
423
|
|
|
424
424
|
this._publishEvent('start', content);
|
|
425
425
|
|
|
@@ -428,15 +428,15 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
428
428
|
|
|
429
429
|
case 'run.execute':
|
|
430
430
|
{
|
|
431
|
-
this[
|
|
431
|
+
this[kStatus] = 'executing';
|
|
432
432
|
const executeMessage = (0, _messageHelper.cloneMessage)(message);
|
|
433
433
|
|
|
434
434
|
if (fields.redelivered && !exec.execution) {
|
|
435
435
|
executeMessage.fields.redelivered = undefined;
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
this[
|
|
439
|
-
this.broker.getQueue('execution-q').assertConsumer(this[
|
|
438
|
+
this[kExecuteMessage] = message;
|
|
439
|
+
this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {
|
|
440
440
|
exclusive: true,
|
|
441
441
|
consumerTag: '_definition-execution'
|
|
442
442
|
});
|
|
@@ -451,10 +451,10 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
451
451
|
|
|
452
452
|
case 'run.end':
|
|
453
453
|
{
|
|
454
|
-
if (this
|
|
455
|
-
this[
|
|
454
|
+
if (this[kStatus] === 'end') break;
|
|
455
|
+
this[kCounters].completed++;
|
|
456
456
|
this.logger.debug(`<${this.executionId} (${this.id})> completed`);
|
|
457
|
-
this[
|
|
457
|
+
this[kStatus] = 'end';
|
|
458
458
|
this.broker.publish('run', 'run.leave', content);
|
|
459
459
|
|
|
460
460
|
this._publishEvent('end', content);
|
|
@@ -475,9 +475,9 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
475
475
|
|
|
476
476
|
case 'run.discarded':
|
|
477
477
|
{
|
|
478
|
-
if (this
|
|
479
|
-
this[
|
|
480
|
-
this[
|
|
478
|
+
if (this[kStatus] === 'discarded') break;
|
|
479
|
+
this[kCounters].discarded++;
|
|
480
|
+
this[kStatus] = 'discarded';
|
|
481
481
|
this.broker.publish('run', 'run.leave', content);
|
|
482
482
|
break;
|
|
483
483
|
}
|
|
@@ -485,7 +485,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
485
485
|
case 'run.leave':
|
|
486
486
|
{
|
|
487
487
|
message.ack();
|
|
488
|
-
this[
|
|
488
|
+
this[kStatus] = undefined;
|
|
489
489
|
|
|
490
490
|
this._deactivateRunConsumers();
|
|
491
491
|
|
|
@@ -500,7 +500,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
500
500
|
|
|
501
501
|
proto._onResumeMessage = function onResumeMessage(message) {
|
|
502
502
|
message.ack();
|
|
503
|
-
const stateMessage = this[
|
|
503
|
+
const stateMessage = this[kStateMessage];
|
|
504
504
|
|
|
505
505
|
switch (stateMessage.fields.routingKey) {
|
|
506
506
|
case 'run.discarded':
|
|
@@ -546,8 +546,8 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
-
const executeMessage = this[
|
|
550
|
-
this[
|
|
549
|
+
const executeMessage = this[kExecuteMessage];
|
|
550
|
+
this[kExecuteMessage] = null;
|
|
551
551
|
executeMessage.ack();
|
|
552
552
|
};
|
|
553
553
|
|
|
@@ -570,7 +570,7 @@ proto._publishEvent = function publishEvent(action, content, msgOpts) {
|
|
|
570
570
|
};
|
|
571
571
|
|
|
572
572
|
proto._onStop = function onStop() {
|
|
573
|
-
this[
|
|
573
|
+
this[kStopped] = true;
|
|
574
574
|
|
|
575
575
|
this._deactivateRunConsumers();
|
|
576
576
|
|
|
@@ -587,7 +587,7 @@ proto._onBrokerReturnFn = function onBrokerReturn(message) {
|
|
|
587
587
|
};
|
|
588
588
|
|
|
589
589
|
proto._reset = function reset() {
|
|
590
|
-
this[
|
|
590
|
+
this[kExec].executionId = undefined;
|
|
591
591
|
|
|
592
592
|
this._deactivateRunConsumers();
|
|
593
593
|
|