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
|
@@ -23,19 +23,19 @@ var _Errors = require("../error/Errors");
|
|
|
23
23
|
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
25
|
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
26
|
+
const kActivityDef = Symbol.for('activityDefinition');
|
|
27
|
+
const kBpmnIo = Symbol.for('bpmnIo');
|
|
28
|
+
const kConsuming = Symbol.for('consuming');
|
|
29
|
+
const kCounters = Symbol.for('counters');
|
|
30
|
+
const kEventDefinitions = Symbol.for('eventDefinitions');
|
|
31
|
+
const kExec = Symbol.for('exec');
|
|
32
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
33
|
+
const kExtensions = Symbol.for('extensions');
|
|
34
|
+
const kFlags = Symbol.for('flags');
|
|
35
|
+
const kFlows = Symbol.for('flows');
|
|
36
|
+
const kFormatter = Symbol.for('formatter');
|
|
37
|
+
const kMessageHandlers = Symbol.for('messageHandlers');
|
|
38
|
+
const kStateMessage = Symbol.for('stateMessage');
|
|
39
39
|
var _default = Activity;
|
|
40
40
|
exports.default = _default;
|
|
41
41
|
|
|
@@ -50,7 +50,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
50
50
|
attachedTo: attachedToRef,
|
|
51
51
|
eventDefinitions
|
|
52
52
|
} = behaviour;
|
|
53
|
-
this[
|
|
53
|
+
this[kActivityDef] = activityDef;
|
|
54
54
|
this.id = id;
|
|
55
55
|
this.type = type;
|
|
56
56
|
this.name = name;
|
|
@@ -62,7 +62,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
62
62
|
this.logger = context.environment.Logger(type.toLowerCase());
|
|
63
63
|
this.environment = context.environment;
|
|
64
64
|
this.context = context;
|
|
65
|
-
this[
|
|
65
|
+
this[kCounters] = {
|
|
66
66
|
taken: 0,
|
|
67
67
|
discarded: 0
|
|
68
68
|
};
|
|
@@ -89,7 +89,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
89
89
|
const inboundAssociations = context.getInboundAssociations(id);
|
|
90
90
|
const inboundTriggers = attachedToActivity ? [attachedToActivity] : inboundSequenceFlows.slice();
|
|
91
91
|
const outboundSequenceFlows = context.getOutboundSequenceFlows(id);
|
|
92
|
-
const flows = this[
|
|
92
|
+
const flows = this[kFlows] = {
|
|
93
93
|
inboundSequenceFlows,
|
|
94
94
|
inboundAssociations,
|
|
95
95
|
inboundJoinFlows: [],
|
|
@@ -99,7 +99,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
99
99
|
};
|
|
100
100
|
const isForCompensation = !!behaviour.isForCompensation;
|
|
101
101
|
const isParallelJoin = activityDef.isParallelGateway && flows.inboundSequenceFlows.length > 1;
|
|
102
|
-
this[
|
|
102
|
+
this[kFlags] = {
|
|
103
103
|
isEnd: flows.outboundSequenceFlows.length === 0,
|
|
104
104
|
isStart: flows.inboundSequenceFlows.length === 0 && !attachedTo && !behaviour.triggeredByEvent && !isForCompensation,
|
|
105
105
|
isSubProcess: activityDef.isSubProcess,
|
|
@@ -110,8 +110,8 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
110
110
|
isParallelJoin,
|
|
111
111
|
isThrowing: activityDef.isThrowing
|
|
112
112
|
};
|
|
113
|
-
this[
|
|
114
|
-
this[
|
|
113
|
+
this[kExec] = {};
|
|
114
|
+
this[kMessageHandlers] = {
|
|
115
115
|
onInbound: isParallelJoin ? this._onJoinInbound.bind(this) : this._onInbound.bind(this),
|
|
116
116
|
onRunMessage: this._onRunMessage.bind(this),
|
|
117
117
|
onApiMessage: this._onApiMessage.bind(this),
|
|
@@ -144,7 +144,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
this[
|
|
147
|
+
this[kEventDefinitions] = eventDefinitions && eventDefinitions.map(ed => new ed.Behaviour(this, ed, this.context));
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
const proto = Activity.prototype;
|
|
@@ -152,7 +152,7 @@ Object.defineProperty(proto, 'counters', {
|
|
|
152
152
|
enumerable: true,
|
|
153
153
|
|
|
154
154
|
get() {
|
|
155
|
-
return { ...this[
|
|
155
|
+
return { ...this[kCounters]
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -161,7 +161,7 @@ Object.defineProperty(proto, 'execution', {
|
|
|
161
161
|
enumerable: true,
|
|
162
162
|
|
|
163
163
|
get() {
|
|
164
|
-
return this[
|
|
164
|
+
return this[kExec].execution;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
});
|
|
@@ -169,7 +169,7 @@ Object.defineProperty(proto, 'executionId', {
|
|
|
169
169
|
enumerable: true,
|
|
170
170
|
|
|
171
171
|
get() {
|
|
172
|
-
return this[
|
|
172
|
+
return this[kExec].executionId;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
});
|
|
@@ -177,8 +177,8 @@ Object.defineProperty(proto, 'bpmnIo', {
|
|
|
177
177
|
enumerable: true,
|
|
178
178
|
|
|
179
179
|
get() {
|
|
180
|
-
if (
|
|
181
|
-
const bpmnIo = this[
|
|
180
|
+
if (kBpmnIo in this) return this[kBpmnIo];
|
|
181
|
+
const bpmnIo = this[kBpmnIo] = new _BpmnIO.default(this, this.context);
|
|
182
182
|
return bpmnIo;
|
|
183
183
|
}
|
|
184
184
|
|
|
@@ -187,8 +187,8 @@ Object.defineProperty(proto, 'extensions', {
|
|
|
187
187
|
enumerable: true,
|
|
188
188
|
|
|
189
189
|
get() {
|
|
190
|
-
if (
|
|
191
|
-
const extensions = this[
|
|
190
|
+
if (kExtensions in this) return this[kExtensions];
|
|
191
|
+
const extensions = this[kExtensions] = this.context.loadExtensions(this);
|
|
192
192
|
return extensions;
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -197,10 +197,10 @@ Object.defineProperty(proto, 'formatter', {
|
|
|
197
197
|
enumerable: true,
|
|
198
198
|
|
|
199
199
|
get() {
|
|
200
|
-
let formatter = this[
|
|
200
|
+
let formatter = this[kFormatter];
|
|
201
201
|
if (formatter) return formatter;
|
|
202
202
|
const broker = this.broker;
|
|
203
|
-
formatter = this[
|
|
203
|
+
formatter = this[kFormatter] = new _MessageFormatter.Formatter({
|
|
204
204
|
id: this.id,
|
|
205
205
|
broker,
|
|
206
206
|
logger: this.logger
|
|
@@ -213,7 +213,7 @@ Object.defineProperty(proto, 'isRunning', {
|
|
|
213
213
|
enumerable: true,
|
|
214
214
|
|
|
215
215
|
get() {
|
|
216
|
-
if (!this[
|
|
216
|
+
if (!this[kConsuming]) return false;
|
|
217
217
|
return !!this.status;
|
|
218
218
|
}
|
|
219
219
|
|
|
@@ -222,7 +222,7 @@ Object.defineProperty(proto, 'outbound', {
|
|
|
222
222
|
enumerable: true,
|
|
223
223
|
|
|
224
224
|
get() {
|
|
225
|
-
return this[
|
|
225
|
+
return this[kFlows].outboundSequenceFlows;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
});
|
|
@@ -230,7 +230,7 @@ Object.defineProperty(proto, 'inbound', {
|
|
|
230
230
|
enumerable: true,
|
|
231
231
|
|
|
232
232
|
get() {
|
|
233
|
-
return this[
|
|
233
|
+
return this[kFlows].inboundSequenceFlows;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
});
|
|
@@ -238,7 +238,7 @@ Object.defineProperty(proto, 'isEnd', {
|
|
|
238
238
|
enumerable: true,
|
|
239
239
|
|
|
240
240
|
get() {
|
|
241
|
-
return this[
|
|
241
|
+
return this[kFlags].isEnd;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
});
|
|
@@ -246,7 +246,7 @@ Object.defineProperty(proto, 'isStart', {
|
|
|
246
246
|
enumerable: true,
|
|
247
247
|
|
|
248
248
|
get() {
|
|
249
|
-
return this[
|
|
249
|
+
return this[kFlags].isStart;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
});
|
|
@@ -254,7 +254,7 @@ Object.defineProperty(proto, 'isSubProcess', {
|
|
|
254
254
|
enumerable: true,
|
|
255
255
|
|
|
256
256
|
get() {
|
|
257
|
-
return this[
|
|
257
|
+
return this[kFlags].isSubProcess;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
});
|
|
@@ -262,7 +262,7 @@ Object.defineProperty(proto, 'isMultiInstance', {
|
|
|
262
262
|
enumerable: true,
|
|
263
263
|
|
|
264
264
|
get() {
|
|
265
|
-
return this[
|
|
265
|
+
return this[kFlags].isMultiInstance;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
});
|
|
@@ -270,7 +270,7 @@ Object.defineProperty(proto, 'isThrowing', {
|
|
|
270
270
|
enumerable: true,
|
|
271
271
|
|
|
272
272
|
get() {
|
|
273
|
-
return this[
|
|
273
|
+
return this[kFlags].isThrowing;
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
});
|
|
@@ -278,7 +278,7 @@ Object.defineProperty(proto, 'isForCompensation', {
|
|
|
278
278
|
enumerable: true,
|
|
279
279
|
|
|
280
280
|
get() {
|
|
281
|
-
return this[
|
|
281
|
+
return this[kFlags].isForCompensation;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
});
|
|
@@ -286,7 +286,7 @@ Object.defineProperty(proto, 'triggeredByEvent', {
|
|
|
286
286
|
enumerable: true,
|
|
287
287
|
|
|
288
288
|
get() {
|
|
289
|
-
return this[
|
|
289
|
+
return this[kActivityDef].triggeredByEvent;
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
});
|
|
@@ -294,7 +294,7 @@ Object.defineProperty(proto, 'attachedTo', {
|
|
|
294
294
|
enumerable: true,
|
|
295
295
|
|
|
296
296
|
get() {
|
|
297
|
-
const attachedToId = this[
|
|
297
|
+
const attachedToId = this[kFlags].attachedTo;
|
|
298
298
|
if (!attachedToId) return null;
|
|
299
299
|
return this.getActivityById(attachedToId);
|
|
300
300
|
}
|
|
@@ -304,13 +304,13 @@ Object.defineProperty(proto, 'eventDefinitions', {
|
|
|
304
304
|
enumerable: true,
|
|
305
305
|
|
|
306
306
|
get() {
|
|
307
|
-
return this[
|
|
307
|
+
return this[kEventDefinitions];
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
});
|
|
311
311
|
|
|
312
312
|
proto.activate = function activate() {
|
|
313
|
-
if (this[
|
|
313
|
+
if (this[kFlags].isForCompensation) return;
|
|
314
314
|
return this._consumeInbound();
|
|
315
315
|
};
|
|
316
316
|
|
|
@@ -322,7 +322,7 @@ proto.deactivate = function deactivate() {
|
|
|
322
322
|
|
|
323
323
|
proto.init = function init(initContent) {
|
|
324
324
|
const id = this.id;
|
|
325
|
-
const exec = this[
|
|
325
|
+
const exec = this[kExec];
|
|
326
326
|
const executionId = exec.initExecutionId = exec.initExecutionId || (0, _shared.getUniqueId)(id);
|
|
327
327
|
this.logger.debug(`<${id}> initialized with executionId <${executionId}>`);
|
|
328
328
|
|
|
@@ -334,7 +334,7 @@ proto.init = function init(initContent) {
|
|
|
334
334
|
proto.run = function run(runContent) {
|
|
335
335
|
const id = this.id;
|
|
336
336
|
if (this.isRunning) throw new Error(`activity <${id}> is already running`);
|
|
337
|
-
const exec = this[
|
|
337
|
+
const exec = this[kExec];
|
|
338
338
|
const executionId = exec.executionId = exec.initExecutionId || (0, _shared.getUniqueId)(id);
|
|
339
339
|
exec.initExecutionId = null;
|
|
340
340
|
|
|
@@ -356,9 +356,9 @@ proto.recover = function recover(state) {
|
|
|
356
356
|
if (!state) return;
|
|
357
357
|
this.stopped = state.stopped;
|
|
358
358
|
this.status = state.status;
|
|
359
|
-
const exec = this[
|
|
359
|
+
const exec = this[kExec];
|
|
360
360
|
exec.executionId = state.executionId;
|
|
361
|
-
this[
|
|
361
|
+
this[kCounters] = { ...this[kCounters],
|
|
362
362
|
...state.counters
|
|
363
363
|
};
|
|
364
364
|
|
|
@@ -371,7 +371,7 @@ proto.recover = function recover(state) {
|
|
|
371
371
|
};
|
|
372
372
|
|
|
373
373
|
proto.resume = function resume() {
|
|
374
|
-
if (this[
|
|
374
|
+
if (this[kConsuming]) {
|
|
375
375
|
throw new Error(`cannot resume running activity <${this.id}>`);
|
|
376
376
|
}
|
|
377
377
|
|
|
@@ -391,26 +391,26 @@ proto.resume = function resume() {
|
|
|
391
391
|
|
|
392
392
|
proto.discard = function discard(discardContent) {
|
|
393
393
|
if (!this.status) return this._runDiscard(discardContent);
|
|
394
|
-
const execution = this[
|
|
394
|
+
const execution = this[kExec].execution;
|
|
395
395
|
if (execution && !execution.completed) return execution.discard();
|
|
396
396
|
|
|
397
397
|
this._deactivateRunConsumers();
|
|
398
398
|
|
|
399
399
|
const broker = this.broker;
|
|
400
400
|
broker.getQueue('run-q').purge();
|
|
401
|
-
broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(this[
|
|
401
|
+
broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(this[kStateMessage].content));
|
|
402
402
|
|
|
403
403
|
this._consumeRunQ();
|
|
404
404
|
};
|
|
405
405
|
|
|
406
406
|
proto.stop = function stop() {
|
|
407
|
-
if (!this[
|
|
407
|
+
if (!this[kConsuming]) return;
|
|
408
408
|
return this.getApi().stop();
|
|
409
409
|
};
|
|
410
410
|
|
|
411
411
|
proto.next = function next() {
|
|
412
412
|
if (!this.environment.settings.step) return;
|
|
413
|
-
const stateMessage = this[
|
|
413
|
+
const stateMessage = this[kStateMessage];
|
|
414
414
|
if (!stateMessage) return;
|
|
415
415
|
if (this.status === 'executing') return false;
|
|
416
416
|
if (this.status === 'formatting') return false;
|
|
@@ -426,13 +426,13 @@ proto.shake = function shake() {
|
|
|
426
426
|
};
|
|
427
427
|
|
|
428
428
|
proto.evaluateOutbound = function evaluateOutbound(fromMessage, discardRestAtTake, callback) {
|
|
429
|
-
return this[
|
|
429
|
+
return this[kFlows].outboundEvaluator.evaluate(fromMessage, discardRestAtTake, callback);
|
|
430
430
|
};
|
|
431
431
|
|
|
432
432
|
proto.getState = function getState() {
|
|
433
433
|
const msg = this._createMessage();
|
|
434
434
|
|
|
435
|
-
const exec = this[
|
|
435
|
+
const exec = this[kExec];
|
|
436
436
|
return { ...msg,
|
|
437
437
|
executionId: exec.executionId,
|
|
438
438
|
stopped: this.stopped,
|
|
@@ -445,9 +445,9 @@ proto.getState = function getState() {
|
|
|
445
445
|
};
|
|
446
446
|
|
|
447
447
|
proto.getApi = function getApi(message) {
|
|
448
|
-
const execution = this[
|
|
448
|
+
const execution = this[kExec].execution;
|
|
449
449
|
if (execution && !execution.completed) return execution.getApi(message);
|
|
450
|
-
return (0, _Api.ActivityApi)(this.broker, message || this[
|
|
450
|
+
return (0, _Api.ActivityApi)(this.broker, message || this[kStateMessage]);
|
|
451
451
|
};
|
|
452
452
|
|
|
453
453
|
proto.getActivityById = function getActivityById(elementId) {
|
|
@@ -455,7 +455,7 @@ proto.getActivityById = function getActivityById(elementId) {
|
|
|
455
455
|
};
|
|
456
456
|
|
|
457
457
|
proto._runDiscard = function runDiscard(discardContent) {
|
|
458
|
-
const exec = this[
|
|
458
|
+
const exec = this[kExec];
|
|
459
459
|
const executionId = exec.executionId = exec.initExecutionId || (0, _shared.getUniqueId)(this.id);
|
|
460
460
|
exec.initExecutionId = null;
|
|
461
461
|
|
|
@@ -473,7 +473,7 @@ proto._runDiscard = function runDiscard(discardContent) {
|
|
|
473
473
|
proto._discardRun = function discardRun() {
|
|
474
474
|
const status = this.status;
|
|
475
475
|
if (!status) return;
|
|
476
|
-
const execution = this[
|
|
476
|
+
const execution = this[kExec].execution;
|
|
477
477
|
if (execution && !execution.completed) return;
|
|
478
478
|
|
|
479
479
|
switch (status) {
|
|
@@ -488,7 +488,7 @@ proto._discardRun = function discardRun() {
|
|
|
488
488
|
if (this.extensions) this.extensions.deactivate();
|
|
489
489
|
const broker = this.broker;
|
|
490
490
|
broker.getQueue('run-q').purge();
|
|
491
|
-
broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(this[
|
|
491
|
+
broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(this[kStateMessage].content));
|
|
492
492
|
|
|
493
493
|
this._consumeRunQ();
|
|
494
494
|
};
|
|
@@ -506,28 +506,28 @@ proto._shakeOutbound = function shakeOutbound(sourceMessage) {
|
|
|
506
506
|
type: 'shake'
|
|
507
507
|
});
|
|
508
508
|
|
|
509
|
-
if (this[
|
|
509
|
+
if (this[kFlags].isEnd) {
|
|
510
510
|
return broker.publish('event', 'activity.shake.end', message.content, {
|
|
511
511
|
persistent: false,
|
|
512
512
|
type: 'shake'
|
|
513
513
|
});
|
|
514
514
|
}
|
|
515
515
|
|
|
516
|
-
for (const flow of this[
|
|
516
|
+
for (const flow of this[kFlows].outboundSequenceFlows) flow.shake(message);
|
|
517
517
|
};
|
|
518
518
|
|
|
519
519
|
proto._consumeInbound = function consumeInbound() {
|
|
520
520
|
if (this.status) return;
|
|
521
521
|
const inboundQ = this.broker.getQueue('inbound-q');
|
|
522
522
|
|
|
523
|
-
if (this[
|
|
524
|
-
return inboundQ.consume(this[
|
|
523
|
+
if (this[kFlags].isParallelJoin) {
|
|
524
|
+
return inboundQ.consume(this[kMessageHandlers].onInbound, {
|
|
525
525
|
consumerTag: '_run-on-inbound',
|
|
526
526
|
prefetch: 1000
|
|
527
527
|
});
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
-
return inboundQ.consume(this[
|
|
530
|
+
return inboundQ.consume(this[kMessageHandlers].onInbound, {
|
|
531
531
|
consumerTag: '_run-on-inbound'
|
|
532
532
|
});
|
|
533
533
|
};
|
|
@@ -580,7 +580,7 @@ proto._onJoinInbound = function onJoinInbound(routingKey, message) {
|
|
|
580
580
|
inboundSequenceFlows,
|
|
581
581
|
inboundJoinFlows,
|
|
582
582
|
inboundTriggers
|
|
583
|
-
} = this[
|
|
583
|
+
} = this[kFlows];
|
|
584
584
|
const idx = inboundJoinFlows.findIndex(msg => msg.content.id === content.id);
|
|
585
585
|
inboundJoinFlows.push(message);
|
|
586
586
|
if (idx > -1) return;
|
|
@@ -630,7 +630,7 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
|
630
630
|
case 'activity.enter':
|
|
631
631
|
case 'activity.discard':
|
|
632
632
|
{
|
|
633
|
-
if (content.id === this[
|
|
633
|
+
if (content.id === this[kFlags].attachedTo) {
|
|
634
634
|
inboundQ.queueMessage(fields, (0, _messageHelper.cloneContent)(content), properties);
|
|
635
635
|
}
|
|
636
636
|
|
|
@@ -655,7 +655,7 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
|
655
655
|
|
|
656
656
|
case 'association.complete':
|
|
657
657
|
{
|
|
658
|
-
if (!this[
|
|
658
|
+
if (!this[kFlags].isForCompensation) break;
|
|
659
659
|
inboundQ.queueMessage(fields, (0, _messageHelper.cloneContent)(content), properties);
|
|
660
660
|
const compensationId = `${(0, _shared.brokerSafeId)(id)}_${(0, _shared.brokerSafeId)(content.sequenceId)}`;
|
|
661
661
|
|
|
@@ -671,9 +671,9 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
|
671
671
|
};
|
|
672
672
|
|
|
673
673
|
proto._consumeRunQ = function consumeRunQ() {
|
|
674
|
-
if (this[
|
|
675
|
-
this[
|
|
676
|
-
this.broker.getQueue('run-q').assertConsumer(this[
|
|
674
|
+
if (this[kConsuming]) return;
|
|
675
|
+
this[kConsuming] = true;
|
|
676
|
+
this.broker.getQueue('run-q').assertConsumer(this[kMessageHandlers].onRunMessage, {
|
|
677
677
|
exclusive: true,
|
|
678
678
|
consumerTag: '_activity-run'
|
|
679
679
|
});
|
|
@@ -709,7 +709,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
709
709
|
const correlationId = message.properties.correlationId;
|
|
710
710
|
const id = this.id;
|
|
711
711
|
const step = this.environment.settings.step;
|
|
712
|
-
this[
|
|
712
|
+
this[kStateMessage] = message;
|
|
713
713
|
|
|
714
714
|
switch (routingKey) {
|
|
715
715
|
case 'run.enter':
|
|
@@ -718,7 +718,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
718
718
|
this.status = 'entered';
|
|
719
719
|
|
|
720
720
|
if (!isRedelivered) {
|
|
721
|
-
this[
|
|
721
|
+
this[kExec].execution = null;
|
|
722
722
|
}
|
|
723
723
|
|
|
724
724
|
if (this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(message), this);
|
|
@@ -733,7 +733,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
733
733
|
{
|
|
734
734
|
this.logger.debug(`<${id}> discard`, isRedelivered ? 'redelivered' : '');
|
|
735
735
|
this.status = 'discard';
|
|
736
|
-
this[
|
|
736
|
+
this[kExec].execution = null;
|
|
737
737
|
if (this.extensions) this.extensions.activate((0, _messageHelper.cloneMessage)(message), this);
|
|
738
738
|
if (this.bpmnIo) this.bpmnIo.activate(message);
|
|
739
739
|
|
|
@@ -771,7 +771,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
771
771
|
const execution = this.execution;
|
|
772
772
|
|
|
773
773
|
if (!isRedelivered && execution) {
|
|
774
|
-
this[
|
|
774
|
+
this[kExecuteMessage] = message;
|
|
775
775
|
return execution.passthrough(message);
|
|
776
776
|
}
|
|
777
777
|
}
|
|
@@ -779,12 +779,12 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
779
779
|
case 'run.execute':
|
|
780
780
|
{
|
|
781
781
|
this.status = 'executing';
|
|
782
|
-
this[
|
|
783
|
-
this.broker.getQueue('execution-q').assertConsumer(this[
|
|
782
|
+
this[kExecuteMessage] = message;
|
|
783
|
+
this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {
|
|
784
784
|
exclusive: true,
|
|
785
785
|
consumerTag: '_activity-execution'
|
|
786
786
|
});
|
|
787
|
-
const exec = this[
|
|
787
|
+
const exec = this[kExec];
|
|
788
788
|
if (!exec.execution) exec.execution = new _ActivityExecution.default(this, this.context);
|
|
789
789
|
|
|
790
790
|
if (isRedelivered) {
|
|
@@ -802,7 +802,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
802
802
|
case 'run.end':
|
|
803
803
|
{
|
|
804
804
|
if (this.status === 'end') break;
|
|
805
|
-
this[
|
|
805
|
+
this[kCounters].taken++;
|
|
806
806
|
this.status = 'end';
|
|
807
807
|
if (isRedelivered) break;
|
|
808
808
|
return this._doRunLeave(message, false, () => {
|
|
@@ -828,7 +828,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
828
828
|
case 'run.discarded':
|
|
829
829
|
{
|
|
830
830
|
this.logger.debug(`<${content.executionId} (${id})> discarded`);
|
|
831
|
-
this[
|
|
831
|
+
this[kCounters].discarded++;
|
|
832
832
|
this.status = 'discarded';
|
|
833
833
|
content.outbound = undefined;
|
|
834
834
|
|
|
@@ -886,7 +886,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
886
886
|
};
|
|
887
887
|
|
|
888
888
|
proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
889
|
-
const executeMessage = this[
|
|
889
|
+
const executeMessage = this[kExecuteMessage];
|
|
890
890
|
const content = (0, _messageHelper.cloneContent)({ ...executeMessage.content,
|
|
891
891
|
...message.content,
|
|
892
892
|
executionId: executeMessage.content.executionId,
|
|
@@ -949,8 +949,8 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
|
949
949
|
|
|
950
950
|
proto._ackRunExecuteMessage = function ackRunExecuteMessage() {
|
|
951
951
|
if (this.environment.settings.step) return;
|
|
952
|
-
const executeMessage = this[
|
|
953
|
-
this[
|
|
952
|
+
const executeMessage = this[kExecuteMessage];
|
|
953
|
+
this[kExecuteMessage] = null;
|
|
954
954
|
executeMessage.ack();
|
|
955
955
|
};
|
|
956
956
|
|
|
@@ -988,12 +988,12 @@ proto._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
|
|
|
988
988
|
};
|
|
989
989
|
|
|
990
990
|
proto._doOutbound = function doOutbound(fromMessage, isDiscarded, callback) {
|
|
991
|
-
const outboundSequenceFlows = this[
|
|
991
|
+
const outboundSequenceFlows = this[kFlows].outboundSequenceFlows;
|
|
992
992
|
if (!outboundSequenceFlows.length) return callback(null, []);
|
|
993
993
|
const fromContent = fromMessage.content;
|
|
994
994
|
let discardSequence = fromContent.discardSequence;
|
|
995
995
|
|
|
996
|
-
if (isDiscarded && !discardSequence && this[
|
|
996
|
+
if (isDiscarded && !discardSequence && this[kFlags].attachedTo && fromContent.inbound && fromContent.inbound[0]) {
|
|
997
997
|
discardSequence = [fromContent.inbound[0].id];
|
|
998
998
|
}
|
|
999
999
|
|
|
@@ -1043,7 +1043,7 @@ proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequ
|
|
|
1043
1043
|
|
|
1044
1044
|
proto._onResumeMessage = function onResumeMessage(message) {
|
|
1045
1045
|
message.ack();
|
|
1046
|
-
const stateMessage = this[
|
|
1046
|
+
const stateMessage = this[kStateMessage];
|
|
1047
1047
|
const {
|
|
1048
1048
|
fields
|
|
1049
1049
|
} = stateMessage;
|
|
@@ -1076,9 +1076,9 @@ proto._publishEvent = function publishEvent(state, content, properties = {}) {
|
|
|
1076
1076
|
};
|
|
1077
1077
|
|
|
1078
1078
|
proto._onStop = function onStop(message) {
|
|
1079
|
-
const running = this[
|
|
1079
|
+
const running = this[kConsuming];
|
|
1080
1080
|
this.stopped = true;
|
|
1081
|
-
this[
|
|
1081
|
+
this[kConsuming] = false;
|
|
1082
1082
|
const broker = this.broker;
|
|
1083
1083
|
broker.cancel('_activity-run');
|
|
1084
1084
|
broker.cancel('_activity-api');
|
|
@@ -1094,11 +1094,11 @@ proto._onStop = function onStop(message) {
|
|
|
1094
1094
|
};
|
|
1095
1095
|
|
|
1096
1096
|
proto._consumeApi = function consumeApi() {
|
|
1097
|
-
const executionId = this[
|
|
1097
|
+
const executionId = this[kExec].executionId;
|
|
1098
1098
|
if (!executionId) return;
|
|
1099
1099
|
const broker = this.broker;
|
|
1100
1100
|
broker.cancel('_activity-api');
|
|
1101
|
-
broker.subscribeTmp('api', `activity.*.${executionId}`, this[
|
|
1101
|
+
broker.subscribeTmp('api', `activity.*.${executionId}`, this[kMessageHandlers].onApiMessage, {
|
|
1102
1102
|
noAck: true,
|
|
1103
1103
|
consumerTag: '_activity-api',
|
|
1104
1104
|
priority: 100
|
|
@@ -1142,7 +1142,7 @@ proto._createMessage = function createMessage(override) {
|
|
|
1142
1142
|
} : undefined)
|
|
1143
1143
|
};
|
|
1144
1144
|
|
|
1145
|
-
for (const [flag, value] of Object.entries(this[
|
|
1145
|
+
for (const [flag, value] of Object.entries(this[kFlags])) {
|
|
1146
1146
|
if (value) result[flag] = value;
|
|
1147
1147
|
}
|
|
1148
1148
|
|
|
@@ -1150,7 +1150,7 @@ proto._createMessage = function createMessage(override) {
|
|
|
1150
1150
|
};
|
|
1151
1151
|
|
|
1152
1152
|
proto._getOutboundSequenceFlowById = function getOutboundSequenceFlowById(flowId) {
|
|
1153
|
-
return this[
|
|
1153
|
+
return this[kFlows].outboundSequenceFlows.find(flow => flow.id === flowId);
|
|
1154
1154
|
};
|
|
1155
1155
|
|
|
1156
1156
|
proto._resumeExtensions = function resumeExtensions(message, callback) {
|
|
@@ -1171,7 +1171,7 @@ proto._deactivateRunConsumers = function _deactivateRunConsumers() {
|
|
|
1171
1171
|
broker.cancel('_activity-api');
|
|
1172
1172
|
broker.cancel('_activity-run');
|
|
1173
1173
|
broker.cancel('_activity-execution');
|
|
1174
|
-
this[
|
|
1174
|
+
this[kConsuming] = false;
|
|
1175
1175
|
};
|
|
1176
1176
|
|
|
1177
1177
|
function OutboundEvaluator(activity, outboundFlows) {
|