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
package/src/activity/Activity.js
CHANGED
|
@@ -7,19 +7,19 @@ import {Formatter} from '../MessageFormatter';
|
|
|
7
7
|
import {cloneContent, cloneParent, cloneMessage} from '../messageHelper';
|
|
8
8
|
import {makeErrorFromMessage, ActivityError} from '../error/Errors';
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
10
|
+
const kActivityDef = Symbol.for('activityDefinition');
|
|
11
|
+
const kBpmnIo = Symbol.for('bpmnIo');
|
|
12
|
+
const kConsuming = Symbol.for('consuming');
|
|
13
|
+
const kCounters = Symbol.for('counters');
|
|
14
|
+
const kEventDefinitions = Symbol.for('eventDefinitions');
|
|
15
|
+
const kExec = Symbol.for('exec');
|
|
16
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
17
|
+
const kExtensions = Symbol.for('extensions');
|
|
18
|
+
const kFlags = Symbol.for('flags');
|
|
19
|
+
const kFlows = Symbol.for('flows');
|
|
20
|
+
const kFormatter = Symbol.for('formatter');
|
|
21
|
+
const kMessageHandlers = Symbol.for('messageHandlers');
|
|
22
|
+
const kStateMessage = Symbol.for('stateMessage');
|
|
23
23
|
|
|
24
24
|
export default Activity;
|
|
25
25
|
|
|
@@ -27,7 +27,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
27
27
|
const {id, type = 'activity', name, behaviour = {}} = activityDef;
|
|
28
28
|
const {attachedTo: attachedToRef, eventDefinitions} = behaviour;
|
|
29
29
|
|
|
30
|
-
this[
|
|
30
|
+
this[kActivityDef] = activityDef;
|
|
31
31
|
this.id = id;
|
|
32
32
|
this.type = type;
|
|
33
33
|
this.name = name;
|
|
@@ -37,7 +37,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
37
37
|
this.logger = context.environment.Logger(type.toLowerCase());
|
|
38
38
|
this.environment = context.environment;
|
|
39
39
|
this.context = context;
|
|
40
|
-
this[
|
|
40
|
+
this[kCounters] = {
|
|
41
41
|
taken: 0,
|
|
42
42
|
discarded: 0,
|
|
43
43
|
};
|
|
@@ -60,7 +60,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
60
60
|
const inboundAssociations = context.getInboundAssociations(id);
|
|
61
61
|
const inboundTriggers = attachedToActivity ? [attachedToActivity] : inboundSequenceFlows.slice();
|
|
62
62
|
const outboundSequenceFlows = context.getOutboundSequenceFlows(id);
|
|
63
|
-
const flows = this[
|
|
63
|
+
const flows = this[kFlows] = {
|
|
64
64
|
inboundSequenceFlows,
|
|
65
65
|
inboundAssociations,
|
|
66
66
|
inboundJoinFlows: [],
|
|
@@ -71,7 +71,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
71
71
|
|
|
72
72
|
const isForCompensation = !!behaviour.isForCompensation;
|
|
73
73
|
const isParallelJoin = activityDef.isParallelGateway && flows.inboundSequenceFlows.length > 1;
|
|
74
|
-
this[
|
|
74
|
+
this[kFlags] = {
|
|
75
75
|
isEnd: flows.outboundSequenceFlows.length === 0,
|
|
76
76
|
isStart: flows.inboundSequenceFlows.length === 0 && !attachedTo && !behaviour.triggeredByEvent && !isForCompensation,
|
|
77
77
|
isSubProcess: activityDef.isSubProcess,
|
|
@@ -82,9 +82,9 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
82
82
|
isParallelJoin,
|
|
83
83
|
isThrowing: activityDef.isThrowing,
|
|
84
84
|
};
|
|
85
|
-
this[
|
|
85
|
+
this[kExec] = {};
|
|
86
86
|
|
|
87
|
-
this[
|
|
87
|
+
this[kMessageHandlers] = {
|
|
88
88
|
onInbound: isParallelJoin ? this._onJoinInbound.bind(this) : this._onInbound.bind(this),
|
|
89
89
|
onRunMessage: this._onRunMessage.bind(this),
|
|
90
90
|
onApiMessage: this._onApiMessage.bind(this),
|
|
@@ -104,7 +104,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
this[
|
|
107
|
+
this[kEventDefinitions] = eventDefinitions && eventDefinitions.map((ed) => new ed.Behaviour(this, ed, this.context));
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const proto = Activity.prototype;
|
|
@@ -112,29 +112,29 @@ const proto = Activity.prototype;
|
|
|
112
112
|
Object.defineProperty(proto, 'counters', {
|
|
113
113
|
enumerable: true,
|
|
114
114
|
get() {
|
|
115
|
-
return {...this[
|
|
115
|
+
return {...this[kCounters]};
|
|
116
116
|
},
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
Object.defineProperty(proto, 'execution', {
|
|
120
120
|
enumerable: true,
|
|
121
121
|
get() {
|
|
122
|
-
return this[
|
|
122
|
+
return this[kExec].execution;
|
|
123
123
|
},
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
Object.defineProperty(proto, 'executionId', {
|
|
127
127
|
enumerable: true,
|
|
128
128
|
get() {
|
|
129
|
-
return this[
|
|
129
|
+
return this[kExec].executionId;
|
|
130
130
|
},
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
Object.defineProperty(proto, 'bpmnIo', {
|
|
134
134
|
enumerable: true,
|
|
135
135
|
get() {
|
|
136
|
-
if (
|
|
137
|
-
const bpmnIo = this[
|
|
136
|
+
if (kBpmnIo in this) return this[kBpmnIo];
|
|
137
|
+
const bpmnIo = this[kBpmnIo] = new BpmnIO(this, this.context);
|
|
138
138
|
return bpmnIo;
|
|
139
139
|
},
|
|
140
140
|
});
|
|
@@ -142,8 +142,8 @@ Object.defineProperty(proto, 'bpmnIo', {
|
|
|
142
142
|
Object.defineProperty(proto, 'extensions', {
|
|
143
143
|
enumerable: true,
|
|
144
144
|
get() {
|
|
145
|
-
if (
|
|
146
|
-
const extensions = this[
|
|
145
|
+
if (kExtensions in this) return this[kExtensions];
|
|
146
|
+
const extensions = this[kExtensions] = this.context.loadExtensions(this);
|
|
147
147
|
return extensions;
|
|
148
148
|
},
|
|
149
149
|
});
|
|
@@ -151,11 +151,11 @@ Object.defineProperty(proto, 'extensions', {
|
|
|
151
151
|
Object.defineProperty(proto, 'formatter', {
|
|
152
152
|
enumerable: true,
|
|
153
153
|
get() {
|
|
154
|
-
let formatter = this[
|
|
154
|
+
let formatter = this[kFormatter];
|
|
155
155
|
if (formatter) return formatter;
|
|
156
156
|
|
|
157
157
|
const broker = this.broker;
|
|
158
|
-
formatter = this[
|
|
158
|
+
formatter = this[kFormatter] = new Formatter({
|
|
159
159
|
id: this.id,
|
|
160
160
|
broker,
|
|
161
161
|
logger: this.logger,
|
|
@@ -167,7 +167,7 @@ Object.defineProperty(proto, 'formatter', {
|
|
|
167
167
|
Object.defineProperty(proto, 'isRunning', {
|
|
168
168
|
enumerable: true,
|
|
169
169
|
get() {
|
|
170
|
-
if (!this[
|
|
170
|
+
if (!this[kConsuming]) return false;
|
|
171
171
|
return !!this.status;
|
|
172
172
|
},
|
|
173
173
|
});
|
|
@@ -175,66 +175,66 @@ Object.defineProperty(proto, 'isRunning', {
|
|
|
175
175
|
Object.defineProperty(proto, 'outbound', {
|
|
176
176
|
enumerable: true,
|
|
177
177
|
get() {
|
|
178
|
-
return this[
|
|
178
|
+
return this[kFlows].outboundSequenceFlows;
|
|
179
179
|
},
|
|
180
180
|
});
|
|
181
181
|
|
|
182
182
|
Object.defineProperty(proto, 'inbound', {
|
|
183
183
|
enumerable: true,
|
|
184
184
|
get() {
|
|
185
|
-
return this[
|
|
185
|
+
return this[kFlows].inboundSequenceFlows;
|
|
186
186
|
},
|
|
187
187
|
});
|
|
188
188
|
|
|
189
189
|
Object.defineProperty(proto, 'isEnd', {
|
|
190
190
|
enumerable: true,
|
|
191
191
|
get() {
|
|
192
|
-
return this[
|
|
192
|
+
return this[kFlags].isEnd;
|
|
193
193
|
},
|
|
194
194
|
});
|
|
195
195
|
Object.defineProperty(proto, 'isStart', {
|
|
196
196
|
enumerable: true,
|
|
197
197
|
get() {
|
|
198
|
-
return this[
|
|
198
|
+
return this[kFlags].isStart;
|
|
199
199
|
},
|
|
200
200
|
});
|
|
201
201
|
Object.defineProperty(proto, 'isSubProcess', {
|
|
202
202
|
enumerable: true,
|
|
203
203
|
get() {
|
|
204
|
-
return this[
|
|
204
|
+
return this[kFlags].isSubProcess;
|
|
205
205
|
},
|
|
206
206
|
});
|
|
207
207
|
|
|
208
208
|
Object.defineProperty(proto, 'isMultiInstance', {
|
|
209
209
|
enumerable: true,
|
|
210
210
|
get() {
|
|
211
|
-
return this[
|
|
211
|
+
return this[kFlags].isMultiInstance;
|
|
212
212
|
},
|
|
213
213
|
});
|
|
214
214
|
|
|
215
215
|
Object.defineProperty(proto, 'isThrowing', {
|
|
216
216
|
enumerable: true,
|
|
217
217
|
get() {
|
|
218
|
-
return this[
|
|
218
|
+
return this[kFlags].isThrowing;
|
|
219
219
|
},
|
|
220
220
|
});
|
|
221
221
|
Object.defineProperty(proto, 'isForCompensation', {
|
|
222
222
|
enumerable: true,
|
|
223
223
|
get() {
|
|
224
|
-
return this[
|
|
224
|
+
return this[kFlags].isForCompensation;
|
|
225
225
|
},
|
|
226
226
|
});
|
|
227
227
|
Object.defineProperty(proto, 'triggeredByEvent', {
|
|
228
228
|
enumerable: true,
|
|
229
229
|
get() {
|
|
230
|
-
return this[
|
|
230
|
+
return this[kActivityDef].triggeredByEvent;
|
|
231
231
|
},
|
|
232
232
|
});
|
|
233
233
|
|
|
234
234
|
Object.defineProperty(proto, 'attachedTo', {
|
|
235
235
|
enumerable: true,
|
|
236
236
|
get() {
|
|
237
|
-
const attachedToId = this[
|
|
237
|
+
const attachedToId = this[kFlags].attachedTo;
|
|
238
238
|
if (!attachedToId) return null;
|
|
239
239
|
return this.getActivityById(attachedToId);
|
|
240
240
|
},
|
|
@@ -243,12 +243,12 @@ Object.defineProperty(proto, 'attachedTo', {
|
|
|
243
243
|
Object.defineProperty(proto, 'eventDefinitions', {
|
|
244
244
|
enumerable: true,
|
|
245
245
|
get() {
|
|
246
|
-
return this[
|
|
246
|
+
return this[kEventDefinitions];
|
|
247
247
|
},
|
|
248
248
|
});
|
|
249
249
|
|
|
250
250
|
proto.activate = function activate() {
|
|
251
|
-
if (this[
|
|
251
|
+
if (this[kFlags].isForCompensation) return;
|
|
252
252
|
return this._consumeInbound();
|
|
253
253
|
};
|
|
254
254
|
|
|
@@ -260,7 +260,7 @@ proto.deactivate = function deactivate() {
|
|
|
260
260
|
|
|
261
261
|
proto.init = function init(initContent) {
|
|
262
262
|
const id = this.id;
|
|
263
|
-
const exec = this[
|
|
263
|
+
const exec = this[kExec];
|
|
264
264
|
const executionId = exec.initExecutionId = exec.initExecutionId || getUniqueId(id);
|
|
265
265
|
this.logger.debug(`<${id}> initialized with executionId <${executionId}>`);
|
|
266
266
|
this._publishEvent('init', this._createMessage({...initContent, executionId}));
|
|
@@ -270,7 +270,7 @@ proto.run = function run(runContent) {
|
|
|
270
270
|
const id = this.id;
|
|
271
271
|
if (this.isRunning) throw new Error(`activity <${id}> is already running`);
|
|
272
272
|
|
|
273
|
-
const exec = this[
|
|
273
|
+
const exec = this[kExec];
|
|
274
274
|
const executionId = exec.executionId = exec.initExecutionId || getUniqueId(id);
|
|
275
275
|
exec.initExecutionId = null;
|
|
276
276
|
|
|
@@ -291,10 +291,10 @@ proto.recover = function recover(state) {
|
|
|
291
291
|
|
|
292
292
|
this.stopped = state.stopped;
|
|
293
293
|
this.status = state.status;
|
|
294
|
-
const exec = this[
|
|
294
|
+
const exec = this[kExec];
|
|
295
295
|
exec.executionId = state.executionId;
|
|
296
296
|
|
|
297
|
-
this[
|
|
297
|
+
this[kCounters] = {...this[kCounters], ...state.counters};
|
|
298
298
|
|
|
299
299
|
if (state.execution) {
|
|
300
300
|
exec.execution = new ActivityExecution(this, this.context).recover(state.execution);
|
|
@@ -306,7 +306,7 @@ proto.recover = function recover(state) {
|
|
|
306
306
|
};
|
|
307
307
|
|
|
308
308
|
proto.resume = function resume() {
|
|
309
|
-
if (this[
|
|
309
|
+
if (this[kConsuming]) {
|
|
310
310
|
throw new Error(`cannot resume running activity <${this.id}>`);
|
|
311
311
|
}
|
|
312
312
|
if (!this.status) return this.activate();
|
|
@@ -322,24 +322,24 @@ proto.resume = function resume() {
|
|
|
322
322
|
|
|
323
323
|
proto.discard = function discard(discardContent) {
|
|
324
324
|
if (!this.status) return this._runDiscard(discardContent);
|
|
325
|
-
const execution = this[
|
|
325
|
+
const execution = this[kExec].execution;
|
|
326
326
|
if (execution && !execution.completed) return execution.discard();
|
|
327
327
|
|
|
328
328
|
this._deactivateRunConsumers();
|
|
329
329
|
const broker = this.broker;
|
|
330
330
|
broker.getQueue('run-q').purge();
|
|
331
|
-
broker.publish('run', 'run.discard', cloneContent(this[
|
|
331
|
+
broker.publish('run', 'run.discard', cloneContent(this[kStateMessage].content));
|
|
332
332
|
this._consumeRunQ();
|
|
333
333
|
};
|
|
334
334
|
|
|
335
335
|
proto.stop = function stop() {
|
|
336
|
-
if (!this[
|
|
336
|
+
if (!this[kConsuming]) return;
|
|
337
337
|
return this.getApi().stop();
|
|
338
338
|
};
|
|
339
339
|
|
|
340
340
|
proto.next = function next() {
|
|
341
341
|
if (!this.environment.settings.step) return;
|
|
342
|
-
const stateMessage = this[
|
|
342
|
+
const stateMessage = this[kStateMessage];
|
|
343
343
|
if (!stateMessage) return;
|
|
344
344
|
if (this.status === 'executing') return false;
|
|
345
345
|
if (this.status === 'formatting') return false;
|
|
@@ -353,13 +353,13 @@ proto.shake = function shake() {
|
|
|
353
353
|
};
|
|
354
354
|
|
|
355
355
|
proto.evaluateOutbound = function evaluateOutbound(fromMessage, discardRestAtTake, callback) {
|
|
356
|
-
return this[
|
|
356
|
+
return this[kFlows].outboundEvaluator.evaluate(fromMessage, discardRestAtTake, callback);
|
|
357
357
|
};
|
|
358
358
|
|
|
359
359
|
proto.getState = function getState() {
|
|
360
360
|
const msg = this._createMessage();
|
|
361
361
|
|
|
362
|
-
const exec = this[
|
|
362
|
+
const exec = this[kExec];
|
|
363
363
|
return {
|
|
364
364
|
...msg,
|
|
365
365
|
executionId: exec.executionId,
|
|
@@ -372,9 +372,9 @@ proto.getState = function getState() {
|
|
|
372
372
|
};
|
|
373
373
|
|
|
374
374
|
proto.getApi = function getApi(message) {
|
|
375
|
-
const execution = this[
|
|
375
|
+
const execution = this[kExec].execution;
|
|
376
376
|
if (execution && !execution.completed) return execution.getApi(message);
|
|
377
|
-
return ActivityApi(this.broker, message || this[
|
|
377
|
+
return ActivityApi(this.broker, message || this[kStateMessage]);
|
|
378
378
|
};
|
|
379
379
|
|
|
380
380
|
proto.getActivityById = function getActivityById(elementId) {
|
|
@@ -382,7 +382,7 @@ proto.getActivityById = function getActivityById(elementId) {
|
|
|
382
382
|
};
|
|
383
383
|
|
|
384
384
|
proto._runDiscard = function runDiscard(discardContent) {
|
|
385
|
-
const exec = this[
|
|
385
|
+
const exec = this[kExec];
|
|
386
386
|
const executionId = exec.executionId = exec.initExecutionId || getUniqueId(this.id);
|
|
387
387
|
exec.initExecutionId = null;
|
|
388
388
|
|
|
@@ -398,7 +398,7 @@ proto._discardRun = function discardRun() {
|
|
|
398
398
|
const status = this.status;
|
|
399
399
|
if (!status) return;
|
|
400
400
|
|
|
401
|
-
const execution = this[
|
|
401
|
+
const execution = this[kExec].execution;
|
|
402
402
|
if (execution && !execution.completed) return;
|
|
403
403
|
switch (status) {
|
|
404
404
|
case 'executing':
|
|
@@ -411,7 +411,7 @@ proto._discardRun = function discardRun() {
|
|
|
411
411
|
if (this.extensions) this.extensions.deactivate();
|
|
412
412
|
const broker = this.broker;
|
|
413
413
|
broker.getQueue('run-q').purge();
|
|
414
|
-
broker.publish('run', 'run.discard', cloneContent(this[
|
|
414
|
+
broker.publish('run', 'run.discard', cloneContent(this[kStateMessage].content));
|
|
415
415
|
this._consumeRunQ();
|
|
416
416
|
};
|
|
417
417
|
|
|
@@ -423,21 +423,21 @@ proto._shakeOutbound = function shakeOutbound(sourceMessage) {
|
|
|
423
423
|
const broker = this.broker;
|
|
424
424
|
this.broker.publish('api', 'activity.shake.start', message.content, {persistent: false, type: 'shake'});
|
|
425
425
|
|
|
426
|
-
if (this[
|
|
426
|
+
if (this[kFlags].isEnd) {
|
|
427
427
|
return broker.publish('event', 'activity.shake.end', message.content, {persistent: false, type: 'shake'});
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
-
for (const flow of this[
|
|
430
|
+
for (const flow of this[kFlows].outboundSequenceFlows) flow.shake(message);
|
|
431
431
|
};
|
|
432
432
|
|
|
433
433
|
proto._consumeInbound = function consumeInbound() {
|
|
434
434
|
if (this.status) return;
|
|
435
435
|
const inboundQ = this.broker.getQueue('inbound-q');
|
|
436
|
-
if (this[
|
|
437
|
-
return inboundQ.consume(this[
|
|
436
|
+
if (this[kFlags].isParallelJoin) {
|
|
437
|
+
return inboundQ.consume(this[kMessageHandlers].onInbound, {consumerTag: '_run-on-inbound', prefetch: 1000});
|
|
438
438
|
}
|
|
439
439
|
|
|
440
|
-
return inboundQ.consume(this[
|
|
440
|
+
return inboundQ.consume(this[kMessageHandlers].onInbound, {consumerTag: '_run-on-inbound'});
|
|
441
441
|
};
|
|
442
442
|
|
|
443
443
|
proto._onInbound = function onInbound(routingKey, message) {
|
|
@@ -478,7 +478,7 @@ proto._onInbound = function onInbound(routingKey, message) {
|
|
|
478
478
|
|
|
479
479
|
proto._onJoinInbound = function onJoinInbound(routingKey, message) {
|
|
480
480
|
const {content} = message;
|
|
481
|
-
const {inboundSequenceFlows, inboundJoinFlows, inboundTriggers} = this[
|
|
481
|
+
const {inboundSequenceFlows, inboundJoinFlows, inboundTriggers} = this[kFlows];
|
|
482
482
|
const idx = inboundJoinFlows.findIndex((msg) => msg.content.id === content.id);
|
|
483
483
|
|
|
484
484
|
inboundJoinFlows.push(message);
|
|
@@ -522,7 +522,7 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
|
522
522
|
switch (routingKey) {
|
|
523
523
|
case 'activity.enter':
|
|
524
524
|
case 'activity.discard': {
|
|
525
|
-
if (content.id === this[
|
|
525
|
+
if (content.id === this[kFlags].attachedTo) {
|
|
526
526
|
inboundQ.queueMessage(fields, cloneContent(content), properties);
|
|
527
527
|
}
|
|
528
528
|
break;
|
|
@@ -539,7 +539,7 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
|
539
539
|
return inboundQ.purge();
|
|
540
540
|
}
|
|
541
541
|
case 'association.complete': {
|
|
542
|
-
if (!this[
|
|
542
|
+
if (!this[kFlags].isForCompensation) break;
|
|
543
543
|
|
|
544
544
|
inboundQ.queueMessage(fields, cloneContent(content), properties);
|
|
545
545
|
|
|
@@ -557,10 +557,10 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
|
557
557
|
};
|
|
558
558
|
|
|
559
559
|
proto._consumeRunQ = function consumeRunQ() {
|
|
560
|
-
if (this[
|
|
560
|
+
if (this[kConsuming]) return;
|
|
561
561
|
|
|
562
|
-
this[
|
|
563
|
-
this.broker.getQueue('run-q').assertConsumer(this[
|
|
562
|
+
this[kConsuming] = true;
|
|
563
|
+
this.broker.getQueue('run-q').assertConsumer(this[kMessageHandlers].onRunMessage, {exclusive: true, consumerTag: '_activity-run'});
|
|
564
564
|
};
|
|
565
565
|
|
|
566
566
|
proto._onRunMessage = function onRunMessage(routingKey, message, messageProperties) {
|
|
@@ -591,7 +591,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
591
591
|
|
|
592
592
|
const id = this.id;
|
|
593
593
|
const step = this.environment.settings.step;
|
|
594
|
-
this[
|
|
594
|
+
this[kStateMessage] = message;
|
|
595
595
|
|
|
596
596
|
switch (routingKey) {
|
|
597
597
|
case 'run.enter': {
|
|
@@ -599,7 +599,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
599
599
|
|
|
600
600
|
this.status = 'entered';
|
|
601
601
|
if (!isRedelivered) {
|
|
602
|
-
this[
|
|
602
|
+
this[kExec].execution = null;
|
|
603
603
|
}
|
|
604
604
|
|
|
605
605
|
if (this.extensions) this.extensions.activate(cloneMessage(message), this);
|
|
@@ -612,7 +612,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
612
612
|
this.logger.debug(`<${id}> discard`, isRedelivered ? 'redelivered' : '');
|
|
613
613
|
|
|
614
614
|
this.status = 'discard';
|
|
615
|
-
this[
|
|
615
|
+
this[kExec].execution = null;
|
|
616
616
|
|
|
617
617
|
if (this.extensions) this.extensions.activate(cloneMessage(message), this);
|
|
618
618
|
if (this.bpmnIo) this.bpmnIo.activate(message);
|
|
@@ -636,16 +636,16 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
636
636
|
case 'run.execute.passthrough': {
|
|
637
637
|
const execution = this.execution;
|
|
638
638
|
if (!isRedelivered && execution) {
|
|
639
|
-
this[
|
|
639
|
+
this[kExecuteMessage] = message;
|
|
640
640
|
return execution.passthrough(message);
|
|
641
641
|
}
|
|
642
642
|
}
|
|
643
643
|
case 'run.execute': {
|
|
644
644
|
this.status = 'executing';
|
|
645
|
-
this[
|
|
645
|
+
this[kExecuteMessage] = message;
|
|
646
646
|
|
|
647
|
-
this.broker.getQueue('execution-q').assertConsumer(this[
|
|
648
|
-
const exec = this[
|
|
647
|
+
this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {exclusive: true, consumerTag: '_activity-execution'});
|
|
648
|
+
const exec = this[kExec];
|
|
649
649
|
if (!exec.execution) exec.execution = new ActivityExecution(this, this.context);
|
|
650
650
|
|
|
651
651
|
if (isRedelivered) {
|
|
@@ -662,7 +662,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
662
662
|
case 'run.end': {
|
|
663
663
|
if (this.status === 'end') break;
|
|
664
664
|
|
|
665
|
-
this[
|
|
665
|
+
this[kCounters].taken++;
|
|
666
666
|
|
|
667
667
|
this.status = 'end';
|
|
668
668
|
|
|
@@ -682,7 +682,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
682
682
|
}
|
|
683
683
|
case 'run.discarded': {
|
|
684
684
|
this.logger.debug(`<${content.executionId} (${id})> discarded`);
|
|
685
|
-
this[
|
|
685
|
+
this[kCounters].discarded++;
|
|
686
686
|
|
|
687
687
|
this.status = 'discarded';
|
|
688
688
|
content.outbound = undefined;
|
|
@@ -727,7 +727,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
727
727
|
};
|
|
728
728
|
|
|
729
729
|
proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
730
|
-
const executeMessage = this[
|
|
730
|
+
const executeMessage = this[kExecuteMessage];
|
|
731
731
|
const content = cloneContent({
|
|
732
732
|
...executeMessage.content,
|
|
733
733
|
...message.content,
|
|
@@ -771,8 +771,8 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
|
771
771
|
|
|
772
772
|
proto._ackRunExecuteMessage = function ackRunExecuteMessage() {
|
|
773
773
|
if (this.environment.settings.step) return;
|
|
774
|
-
const executeMessage = this[
|
|
775
|
-
this[
|
|
774
|
+
const executeMessage = this[kExecuteMessage];
|
|
775
|
+
this[kExecuteMessage] = null;
|
|
776
776
|
executeMessage.ack();
|
|
777
777
|
};
|
|
778
778
|
|
|
@@ -798,13 +798,13 @@ proto._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
|
|
|
798
798
|
};
|
|
799
799
|
|
|
800
800
|
proto._doOutbound = function doOutbound(fromMessage, isDiscarded, callback) {
|
|
801
|
-
const outboundSequenceFlows = this[
|
|
801
|
+
const outboundSequenceFlows = this[kFlows].outboundSequenceFlows;
|
|
802
802
|
if (!outboundSequenceFlows.length) return callback(null, []);
|
|
803
803
|
|
|
804
804
|
const fromContent = fromMessage.content;
|
|
805
805
|
|
|
806
806
|
let discardSequence = fromContent.discardSequence;
|
|
807
|
-
if (isDiscarded && !discardSequence && this[
|
|
807
|
+
if (isDiscarded && !discardSequence && this[kFlags].attachedTo && fromContent.inbound && fromContent.inbound[0]) {
|
|
808
808
|
discardSequence = [fromContent.inbound[0].id];
|
|
809
809
|
}
|
|
810
810
|
|
|
@@ -844,7 +844,7 @@ proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequ
|
|
|
844
844
|
proto._onResumeMessage = function onResumeMessage(message) {
|
|
845
845
|
message.ack();
|
|
846
846
|
|
|
847
|
-
const stateMessage = this[
|
|
847
|
+
const stateMessage = this[kStateMessage];
|
|
848
848
|
const {fields} = stateMessage;
|
|
849
849
|
|
|
850
850
|
switch (fields.routingKey) {
|
|
@@ -875,11 +875,11 @@ proto._publishEvent = function publishEvent(state, content, properties = {}) {
|
|
|
875
875
|
};
|
|
876
876
|
|
|
877
877
|
proto._onStop = function onStop(message) {
|
|
878
|
-
const running = this[
|
|
878
|
+
const running = this[kConsuming];
|
|
879
879
|
|
|
880
880
|
this.stopped = true;
|
|
881
881
|
|
|
882
|
-
this[
|
|
882
|
+
this[kConsuming] = false;
|
|
883
883
|
const broker = this.broker;
|
|
884
884
|
broker.cancel('_activity-run');
|
|
885
885
|
broker.cancel('_activity-api');
|
|
@@ -894,11 +894,11 @@ proto._onStop = function onStop(message) {
|
|
|
894
894
|
};
|
|
895
895
|
|
|
896
896
|
proto._consumeApi = function consumeApi() {
|
|
897
|
-
const executionId = this[
|
|
897
|
+
const executionId = this[kExec].executionId;
|
|
898
898
|
if (!executionId) return;
|
|
899
899
|
const broker = this.broker;
|
|
900
900
|
broker.cancel('_activity-api');
|
|
901
|
-
broker.subscribeTmp('api', `activity.*.${executionId}`, this[
|
|
901
|
+
broker.subscribeTmp('api', `activity.*.${executionId}`, this[kMessageHandlers].onApiMessage, {noAck: true, consumerTag: '_activity-api', priority: 100});
|
|
902
902
|
};
|
|
903
903
|
|
|
904
904
|
proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
@@ -926,7 +926,7 @@ proto._createMessage = function createMessage(override) {
|
|
|
926
926
|
...(parent ? {parent: cloneParent(parent)} : undefined),
|
|
927
927
|
};
|
|
928
928
|
|
|
929
|
-
for (const [flag, value] of Object.entries(this[
|
|
929
|
+
for (const [flag, value] of Object.entries(this[kFlags])) {
|
|
930
930
|
if (value) result[flag] = value;
|
|
931
931
|
}
|
|
932
932
|
|
|
@@ -934,7 +934,7 @@ proto._createMessage = function createMessage(override) {
|
|
|
934
934
|
};
|
|
935
935
|
|
|
936
936
|
proto._getOutboundSequenceFlowById = function getOutboundSequenceFlowById(flowId) {
|
|
937
|
-
return this[
|
|
937
|
+
return this[kFlows].outboundSequenceFlows.find((flow) => flow.id === flowId);
|
|
938
938
|
};
|
|
939
939
|
|
|
940
940
|
proto._resumeExtensions = function resumeExtensions(message, callback) {
|
|
@@ -956,7 +956,7 @@ proto._deactivateRunConsumers = function _deactivateRunConsumers() {
|
|
|
956
956
|
broker.cancel('_activity-api');
|
|
957
957
|
broker.cancel('_activity-run');
|
|
958
958
|
broker.cancel('_activity-execution');
|
|
959
|
-
this[
|
|
959
|
+
this[kConsuming] = false;
|
|
960
960
|
};
|
|
961
961
|
|
|
962
962
|
function OutboundEvaluator(activity, outboundFlows) {
|