bpmn-elements 8.2.4 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/dist/{src/Api.js → Api.js} +11 -12
- package/dist/{src/Context.js → Context.js} +26 -27
- package/dist/{src/Environment.js → Environment.js} +15 -16
- package/dist/{src/EventBroker.js → EventBroker.js} +5 -1
- package/dist/{src/Expressions.js → Expressions.js} +1 -1
- package/dist/{src/MessageFormatter.js → MessageFormatter.js} +3 -3
- package/dist/Tracker.js +89 -0
- package/dist/{src/activity → activity}/Activity.js +109 -120
- package/dist/{src/activity → activity}/ActivityExecution.js +28 -32
- package/dist/{src/activity → activity}/Dummy.js +1 -1
- package/dist/{src/activity → activity}/ExecutionScope.js +2 -2
- package/dist/{src/definition → definition}/Definition.js +64 -59
- package/dist/{src/definition → definition}/DefinitionExecution.js +68 -46
- package/dist/{src/error → error}/Errors.js +1 -1
- package/dist/eventDefinitions/CancelEventDefinition.js +127 -0
- package/dist/{src/eventDefinitions → eventDefinitions}/CompensateEventDefinition.js +64 -52
- package/dist/{src/eventDefinitions → eventDefinitions}/ConditionalEventDefinition.js +24 -16
- package/dist/{src/eventDefinitions → eventDefinitions}/ErrorEventDefinition.js +15 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/EscalationEventDefinition.js +12 -13
- package/dist/{src/eventDefinitions → eventDefinitions}/EventDefinitionExecution.js +10 -11
- package/dist/{src/eventDefinitions → eventDefinitions}/LinkEventDefinition.js +14 -15
- package/dist/{src/eventDefinitions → eventDefinitions}/MessageEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/SignalEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/TerminateEventDefinition.js +1 -1
- package/dist/{src/eventDefinitions → eventDefinitions}/TimerEventDefinition.js +15 -16
- package/dist/{src/events → events}/BoundaryEvent.js +39 -25
- package/dist/{src/events → events}/EndEvent.js +3 -3
- package/dist/{src/events → events}/IntermediateCatchEvent.js +3 -3
- package/dist/{src/events → events}/IntermediateThrowEvent.js +3 -3
- package/dist/{src/events → events}/StartEvent.js +8 -9
- package/dist/{src/flows → flows}/Association.js +14 -22
- package/dist/{src/flows → flows}/MessageFlow.js +16 -14
- package/dist/{src/flows → flows}/SequenceFlow.js +16 -18
- package/dist/{src/gateways → gateways}/EventBasedGateway.js +3 -4
- package/dist/{src/gateways → gateways}/ExclusiveGateway.js +2 -2
- package/dist/{src/gateways → gateways}/InclusiveGateway.js +2 -2
- package/dist/{src/gateways → gateways}/ParallelGateway.js +2 -2
- package/dist/index.js +48 -48
- package/dist/{src/io → io}/InputOutputSpecification.js +8 -9
- package/dist/{src/io → io}/Properties.js +7 -8
- package/dist/package.json +3 -0
- package/dist/{src/process → process}/Process.js +44 -40
- package/dist/{src/process → process}/ProcessExecution.js +169 -78
- package/dist/{src/tasks → tasks}/CallActivity.js +7 -8
- package/dist/{src/tasks → tasks}/LoopCharacteristics.js +2 -2
- package/dist/{src/tasks → tasks}/ReceiveTask.js +14 -15
- package/dist/{src/tasks → tasks}/ScriptTask.js +4 -4
- package/dist/{src/tasks → tasks}/ServiceImplementation.js +1 -1
- package/dist/{src/tasks → tasks}/ServiceTask.js +6 -7
- package/dist/{src/tasks → tasks}/SignalTask.js +7 -8
- package/dist/{src/tasks → tasks}/StandardLoopCharacteristics.js +1 -1
- package/dist/{src/tasks → tasks}/SubProcess.js +19 -19
- package/dist/{src/tasks → tasks}/Task.js +2 -2
- package/dist/{src/tasks → tasks}/Transaction.js +1 -1
- package/package.json +31 -31
- package/src/Api.js +11 -13
- package/src/Context.js +26 -28
- package/src/Environment.js +15 -17
- package/src/EventBroker.js +2 -1
- package/src/Expressions.js +1 -1
- package/src/MessageFormatter.js +3 -3
- package/src/Tracker.js +73 -0
- package/src/activity/Activity.js +106 -114
- package/src/activity/ActivityExecution.js +28 -32
- package/src/activity/Dummy.js +1 -1
- package/src/activity/ExecutionScope.js +2 -2
- package/src/definition/Definition.js +65 -64
- package/src/definition/DefinitionExecution.js +71 -47
- package/src/error/Errors.js +1 -1
- package/src/eventDefinitions/CancelEventDefinition.js +32 -78
- package/src/eventDefinitions/CompensateEventDefinition.js +58 -52
- package/src/eventDefinitions/ConditionalEventDefinition.js +25 -17
- package/src/eventDefinitions/ErrorEventDefinition.js +15 -15
- package/src/eventDefinitions/EscalationEventDefinition.js +12 -14
- package/src/eventDefinitions/EventDefinitionExecution.js +10 -12
- package/src/eventDefinitions/LinkEventDefinition.js +14 -16
- package/src/eventDefinitions/MessageEventDefinition.js +13 -15
- package/src/eventDefinitions/SignalEventDefinition.js +13 -15
- package/src/eventDefinitions/TerminateEventDefinition.js +1 -1
- package/src/eventDefinitions/TimerEventDefinition.js +15 -17
- package/src/events/BoundaryEvent.js +34 -24
- package/src/events/EndEvent.js +3 -3
- package/src/events/IntermediateCatchEvent.js +3 -3
- package/src/events/IntermediateThrowEvent.js +3 -3
- package/src/events/StartEvent.js +8 -10
- package/src/flows/Association.js +14 -26
- package/src/flows/MessageFlow.js +14 -15
- package/src/flows/SequenceFlow.js +16 -20
- package/src/gateways/EventBasedGateway.js +3 -4
- package/src/gateways/ExclusiveGateway.js +2 -2
- package/src/gateways/InclusiveGateway.js +2 -2
- package/src/gateways/ParallelGateway.js +2 -2
- package/src/index.js +106 -0
- package/src/io/InputOutputSpecification.js +8 -10
- package/src/io/Properties.js +7 -9
- package/src/process/Process.js +45 -41
- package/src/process/ProcessExecution.js +167 -79
- package/src/tasks/CallActivity.js +7 -9
- package/src/tasks/LoopCharacteristics.js +2 -2
- package/src/tasks/ReceiveTask.js +215 -217
- package/src/tasks/ScriptTask.js +4 -4
- package/src/tasks/ServiceImplementation.js +1 -1
- package/src/tasks/ServiceTask.js +6 -8
- package/src/tasks/SignalTask.js +7 -9
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +19 -20
- package/src/tasks/Task.js +2 -2
- package/src/tasks/Transaction.js +1 -1
- package/types/index.d.ts +520 -0
- package/dist/src/eventDefinitions/CancelEventDefinition.js +0 -184
- package/index.js +0 -106
- /package/dist/{src/ExtensionsMapper.js → ExtensionsMapper.js} +0 -0
- /package/dist/{src/Scripts.js → Scripts.js} +0 -0
- /package/dist/{src/Timers.js → Timers.js} +0 -0
- /package/dist/{src/activity → activity}/Escalation.js +0 -0
- /package/dist/{src/activity → activity}/Message.js +0 -0
- /package/dist/{src/activity → activity}/Signal.js +0 -0
- /package/dist/{src/error → error}/BpmnError.js +0 -0
- /package/dist/{src/getPropertyValue.js → getPropertyValue.js} +0 -0
- /package/dist/{src/io → io}/BpmnIO.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataObject.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataStore.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataStoreReference.js +0 -0
- /package/dist/{src/messageHelper.js → messageHelper.js} +0 -0
- /package/dist/{src/shared.js → shared.js} +0 -0
package/src/activity/Activity.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import ActivityExecution from './ActivityExecution';
|
|
2
|
-
import {
|
|
3
|
-
import {ActivityApi} from '../Api';
|
|
4
|
-
import {ActivityBroker} from '../EventBroker';
|
|
5
|
-
import {Formatter} from '../MessageFormatter';
|
|
6
|
-
import {cloneContent, cloneParent, cloneMessage} from '../messageHelper';
|
|
7
|
-
import {makeErrorFromMessage, ActivityError} from '../error/Errors';
|
|
1
|
+
import ActivityExecution from './ActivityExecution.js';
|
|
2
|
+
import {getUniqueId} from '../shared.js';
|
|
3
|
+
import {ActivityApi} from '../Api.js';
|
|
4
|
+
import {ActivityBroker} from '../EventBroker.js';
|
|
5
|
+
import {Formatter} from '../MessageFormatter.js';
|
|
6
|
+
import {cloneContent, cloneParent, cloneMessage} from '../messageHelper.js';
|
|
7
|
+
import {makeErrorFromMessage, ActivityError} from '../error/Errors.js';
|
|
8
8
|
|
|
9
9
|
const kActivityDef = Symbol.for('activityDefinition');
|
|
10
10
|
const kConsuming = Symbol.for('consuming');
|
|
@@ -18,6 +18,7 @@ const kFlows = Symbol.for('flows');
|
|
|
18
18
|
const kFormatter = Symbol.for('formatter');
|
|
19
19
|
const kMessageHandlers = Symbol.for('messageHandlers');
|
|
20
20
|
const kStateMessage = Symbol.for('stateMessage');
|
|
21
|
+
const kActivated = Symbol.for('activated');
|
|
21
22
|
|
|
22
23
|
export default Activity;
|
|
23
24
|
|
|
@@ -39,6 +40,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
39
40
|
taken: 0,
|
|
40
41
|
discarded: 0,
|
|
41
42
|
};
|
|
43
|
+
const isForCompensation = !!behaviour.isForCompensation;
|
|
42
44
|
|
|
43
45
|
let attachedToActivity, attachedTo;
|
|
44
46
|
if (attachedToRef) {
|
|
@@ -56,7 +58,14 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
56
58
|
|
|
57
59
|
const inboundSequenceFlows = context.getInboundSequenceFlows(id);
|
|
58
60
|
const inboundAssociations = context.getInboundAssociations(id);
|
|
59
|
-
|
|
61
|
+
let inboundTriggers;
|
|
62
|
+
if (attachedToActivity) {
|
|
63
|
+
inboundTriggers = [attachedToActivity];
|
|
64
|
+
} else if (isForCompensation) {
|
|
65
|
+
inboundTriggers = inboundAssociations.slice();
|
|
66
|
+
} else {
|
|
67
|
+
inboundTriggers = inboundSequenceFlows.slice();
|
|
68
|
+
}
|
|
60
69
|
const outboundSequenceFlows = context.getOutboundSequenceFlows(id);
|
|
61
70
|
const flows = this[kFlows] = {
|
|
62
71
|
inboundSequenceFlows,
|
|
@@ -67,7 +76,6 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
67
76
|
outboundEvaluator: new OutboundEvaluator(this, outboundSequenceFlows),
|
|
68
77
|
};
|
|
69
78
|
|
|
70
|
-
const isForCompensation = !!behaviour.isForCompensation;
|
|
71
79
|
const isParallelJoin = activityDef.isParallelGateway && flows.inboundSequenceFlows.length > 1;
|
|
72
80
|
this[kFlags] = {
|
|
73
81
|
isEnd: flows.outboundSequenceFlows.length === 0,
|
|
@@ -89,54 +97,39 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
89
97
|
onExecutionMessage: this._onExecutionMessage.bind(this),
|
|
90
98
|
};
|
|
91
99
|
|
|
92
|
-
const onInboundEvent = this._onInboundEvent.bind(this);
|
|
93
|
-
broker.assertQueue('inbound-q', {durable: true, autoDelete: false});
|
|
94
|
-
if (isForCompensation) {
|
|
95
|
-
for (const trigger of inboundAssociations) {
|
|
96
|
-
trigger.broker.subscribeTmp('event', '#', onInboundEvent, {noAck: true, consumerTag: `_inbound-${id}`});
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
for (const trigger of inboundTriggers) {
|
|
100
|
-
if (trigger.isSequenceFlow) trigger.broker.subscribeTmp('event', 'flow.#', onInboundEvent, {noAck: true, consumerTag: `_inbound-${id}`});
|
|
101
|
-
else trigger.broker.subscribeTmp('event', 'activity.#', onInboundEvent, {noAck: true, consumerTag: `_inbound-${id}`});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
100
|
this[kEventDefinitions] = eventDefinitions && eventDefinitions.map((ed) => new ed.Behaviour(this, ed, this.context));
|
|
106
101
|
this[kExtensions] = context.loadExtensions(this);
|
|
107
102
|
}
|
|
108
103
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Object.defineProperty(proto, 'counters', {
|
|
104
|
+
Object.defineProperty(Activity.prototype, 'counters', {
|
|
112
105
|
enumerable: true,
|
|
113
106
|
get() {
|
|
114
107
|
return {...this[kCounters]};
|
|
115
108
|
},
|
|
116
109
|
});
|
|
117
110
|
|
|
118
|
-
Object.defineProperty(
|
|
111
|
+
Object.defineProperty(Activity.prototype, 'execution', {
|
|
119
112
|
enumerable: true,
|
|
120
113
|
get() {
|
|
121
114
|
return this[kExec].execution;
|
|
122
115
|
},
|
|
123
116
|
});
|
|
124
117
|
|
|
125
|
-
Object.defineProperty(
|
|
118
|
+
Object.defineProperty(Activity.prototype, 'executionId', {
|
|
126
119
|
enumerable: true,
|
|
127
120
|
get() {
|
|
128
121
|
return this[kExec].executionId;
|
|
129
122
|
},
|
|
130
123
|
});
|
|
131
124
|
|
|
132
|
-
Object.defineProperty(
|
|
125
|
+
Object.defineProperty(Activity.prototype, 'extensions', {
|
|
133
126
|
enumerable: true,
|
|
134
127
|
get() {
|
|
135
128
|
return this[kExtensions];
|
|
136
129
|
},
|
|
137
130
|
});
|
|
138
131
|
|
|
139
|
-
Object.defineProperty(
|
|
132
|
+
Object.defineProperty(Activity.prototype, 'bpmnIo', {
|
|
140
133
|
enumerable: true,
|
|
141
134
|
get() {
|
|
142
135
|
const extensions = this[kExtensions];
|
|
@@ -144,7 +137,7 @@ Object.defineProperty(proto, 'bpmnIo', {
|
|
|
144
137
|
},
|
|
145
138
|
});
|
|
146
139
|
|
|
147
|
-
Object.defineProperty(
|
|
140
|
+
Object.defineProperty(Activity.prototype, 'formatter', {
|
|
148
141
|
enumerable: true,
|
|
149
142
|
get() {
|
|
150
143
|
let formatter = this[kFormatter];
|
|
@@ -160,7 +153,7 @@ Object.defineProperty(proto, 'formatter', {
|
|
|
160
153
|
},
|
|
161
154
|
});
|
|
162
155
|
|
|
163
|
-
Object.defineProperty(
|
|
156
|
+
Object.defineProperty(Activity.prototype, 'isRunning', {
|
|
164
157
|
enumerable: true,
|
|
165
158
|
get() {
|
|
166
159
|
if (!this[kConsuming]) return false;
|
|
@@ -168,66 +161,72 @@ Object.defineProperty(proto, 'isRunning', {
|
|
|
168
161
|
},
|
|
169
162
|
});
|
|
170
163
|
|
|
171
|
-
Object.defineProperty(
|
|
164
|
+
Object.defineProperty(Activity.prototype, 'outbound', {
|
|
172
165
|
enumerable: true,
|
|
173
166
|
get() {
|
|
174
167
|
return this[kFlows].outboundSequenceFlows;
|
|
175
168
|
},
|
|
176
169
|
});
|
|
177
170
|
|
|
178
|
-
Object.defineProperty(
|
|
171
|
+
Object.defineProperty(Activity.prototype, 'inbound', {
|
|
179
172
|
enumerable: true,
|
|
180
173
|
get() {
|
|
181
174
|
return this[kFlows].inboundSequenceFlows;
|
|
182
175
|
},
|
|
183
176
|
});
|
|
184
177
|
|
|
185
|
-
Object.defineProperty(
|
|
178
|
+
Object.defineProperty(Activity.prototype, 'isEnd', {
|
|
186
179
|
enumerable: true,
|
|
187
180
|
get() {
|
|
188
181
|
return this[kFlags].isEnd;
|
|
189
182
|
},
|
|
190
183
|
});
|
|
191
|
-
Object.defineProperty(
|
|
184
|
+
Object.defineProperty(Activity.prototype, 'isStart', {
|
|
192
185
|
enumerable: true,
|
|
193
186
|
get() {
|
|
194
187
|
return this[kFlags].isStart;
|
|
195
188
|
},
|
|
196
189
|
});
|
|
197
|
-
Object.defineProperty(
|
|
190
|
+
Object.defineProperty(Activity.prototype, 'isSubProcess', {
|
|
198
191
|
enumerable: true,
|
|
199
192
|
get() {
|
|
200
193
|
return this[kFlags].isSubProcess;
|
|
201
194
|
},
|
|
202
195
|
});
|
|
196
|
+
Object.defineProperty(Activity.prototype, 'isTransaction', {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
get() {
|
|
199
|
+
return this[kFlags].isTransaction;
|
|
200
|
+
},
|
|
201
|
+
});
|
|
203
202
|
|
|
204
|
-
Object.defineProperty(
|
|
203
|
+
Object.defineProperty(Activity.prototype, 'isMultiInstance', {
|
|
205
204
|
enumerable: true,
|
|
206
205
|
get() {
|
|
207
206
|
return this[kFlags].isMultiInstance;
|
|
208
207
|
},
|
|
209
208
|
});
|
|
210
209
|
|
|
211
|
-
Object.defineProperty(
|
|
210
|
+
Object.defineProperty(Activity.prototype, 'isThrowing', {
|
|
212
211
|
enumerable: true,
|
|
213
212
|
get() {
|
|
214
213
|
return this[kFlags].isThrowing;
|
|
215
214
|
},
|
|
216
215
|
});
|
|
217
|
-
Object.defineProperty(
|
|
216
|
+
Object.defineProperty(Activity.prototype, 'isForCompensation', {
|
|
218
217
|
enumerable: true,
|
|
219
218
|
get() {
|
|
220
219
|
return this[kFlags].isForCompensation;
|
|
221
220
|
},
|
|
222
221
|
});
|
|
223
|
-
Object.defineProperty(
|
|
222
|
+
Object.defineProperty(Activity.prototype, 'triggeredByEvent', {
|
|
224
223
|
enumerable: true,
|
|
225
224
|
get() {
|
|
226
225
|
return this[kActivityDef].triggeredByEvent;
|
|
227
226
|
},
|
|
228
227
|
});
|
|
229
228
|
|
|
230
|
-
Object.defineProperty(
|
|
229
|
+
Object.defineProperty(Activity.prototype, 'attachedTo', {
|
|
231
230
|
enumerable: true,
|
|
232
231
|
get() {
|
|
233
232
|
const attachedToId = this[kFlags].attachedTo;
|
|
@@ -236,25 +235,28 @@ Object.defineProperty(proto, 'attachedTo', {
|
|
|
236
235
|
},
|
|
237
236
|
});
|
|
238
237
|
|
|
239
|
-
Object.defineProperty(
|
|
238
|
+
Object.defineProperty(Activity.prototype, 'eventDefinitions', {
|
|
240
239
|
enumerable: true,
|
|
241
240
|
get() {
|
|
242
241
|
return this[kEventDefinitions];
|
|
243
242
|
},
|
|
244
243
|
});
|
|
245
244
|
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
Activity.prototype.activate = function activate() {
|
|
246
|
+
this[kActivated] = true;
|
|
247
|
+
this.addInboundListeners();
|
|
248
248
|
return this._consumeInbound();
|
|
249
249
|
};
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
Activity.prototype.deactivate = function deactivate() {
|
|
252
|
+
this[kActivated] = false;
|
|
252
253
|
const broker = this.broker;
|
|
254
|
+
this.removeInboundListeners();
|
|
253
255
|
broker.cancel('_run-on-inbound');
|
|
254
256
|
broker.cancel('_format-consumer');
|
|
255
257
|
};
|
|
256
258
|
|
|
257
|
-
|
|
259
|
+
Activity.prototype.init = function init(initContent) {
|
|
258
260
|
const id = this.id;
|
|
259
261
|
const exec = this[kExec];
|
|
260
262
|
const executionId = exec.initExecutionId = exec.initExecutionId || getUniqueId(id);
|
|
@@ -262,7 +264,7 @@ proto.init = function init(initContent) {
|
|
|
262
264
|
this._publishEvent('init', this._createMessage({...initContent, executionId}));
|
|
263
265
|
};
|
|
264
266
|
|
|
265
|
-
|
|
267
|
+
Activity.prototype.run = function run(runContent) {
|
|
266
268
|
const id = this.id;
|
|
267
269
|
if (this.isRunning) throw new Error(`activity <${id}> is already running`);
|
|
268
270
|
|
|
@@ -281,7 +283,7 @@ proto.run = function run(runContent) {
|
|
|
281
283
|
this._consumeRunQ();
|
|
282
284
|
};
|
|
283
285
|
|
|
284
|
-
|
|
286
|
+
Activity.prototype.recover = function recover(state) {
|
|
285
287
|
if (this.isRunning) throw new Error(`cannot recover running activity <${this.id}>`);
|
|
286
288
|
if (!state) return;
|
|
287
289
|
|
|
@@ -301,7 +303,7 @@ proto.recover = function recover(state) {
|
|
|
301
303
|
return this;
|
|
302
304
|
};
|
|
303
305
|
|
|
304
|
-
|
|
306
|
+
Activity.prototype.resume = function resume() {
|
|
305
307
|
if (this[kConsuming]) {
|
|
306
308
|
throw new Error(`cannot resume running activity <${this.id}>`);
|
|
307
309
|
}
|
|
@@ -316,7 +318,7 @@ proto.resume = function resume() {
|
|
|
316
318
|
this._consumeRunQ();
|
|
317
319
|
};
|
|
318
320
|
|
|
319
|
-
|
|
321
|
+
Activity.prototype.discard = function discard(discardContent) {
|
|
320
322
|
if (!this.status) return this._runDiscard(discardContent);
|
|
321
323
|
const execution = this[kExec].execution;
|
|
322
324
|
if (execution && !execution.completed) return execution.discard();
|
|
@@ -328,12 +330,29 @@ proto.discard = function discard(discardContent) {
|
|
|
328
330
|
this._consumeRunQ();
|
|
329
331
|
};
|
|
330
332
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
333
|
+
Activity.prototype.addInboundListeners = function addInboundListeners() {
|
|
334
|
+
const onInboundEvent = this._onInboundEvent.bind(this);
|
|
335
|
+
const triggerConsumerTag = `_inbound-${this.id}`;
|
|
336
|
+
for (const trigger of this[kFlows].inboundTriggers) {
|
|
337
|
+
if (trigger.isSequenceFlow) trigger.broker.subscribeTmp('event', 'flow.#', onInboundEvent, {noAck: true, consumerTag: triggerConsumerTag});
|
|
338
|
+
else if (this.isForCompensation) trigger.broker.subscribeTmp('event', 'association.#', onInboundEvent, {noAck: true, consumerTag: triggerConsumerTag});
|
|
339
|
+
else trigger.broker.subscribeTmp('event', 'activity.#', onInboundEvent, {noAck: true, consumerTag: triggerConsumerTag});
|
|
340
|
+
}
|
|
334
341
|
};
|
|
335
342
|
|
|
336
|
-
|
|
343
|
+
Activity.prototype.removeInboundListeners = function removeInboundListeners() {
|
|
344
|
+
const triggerConsumerTag = `_inbound-${this.id}`;
|
|
345
|
+
for (const trigger of this[kFlows].inboundTriggers) {
|
|
346
|
+
trigger.broker.cancel(triggerConsumerTag);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
Activity.prototype.stop = function stop() {
|
|
351
|
+
if (!this[kConsuming]) return this.broker.cancel('_run-on-inbound');
|
|
352
|
+
return this.getApi(this[kStateMessage]).stop();
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
Activity.prototype.next = function next() {
|
|
337
356
|
if (!this.environment.settings.step) return;
|
|
338
357
|
const stateMessage = this[kStateMessage];
|
|
339
358
|
if (!stateMessage) return;
|
|
@@ -344,15 +363,15 @@ proto.next = function next() {
|
|
|
344
363
|
return current;
|
|
345
364
|
};
|
|
346
365
|
|
|
347
|
-
|
|
366
|
+
Activity.prototype.shake = function shake() {
|
|
348
367
|
this._shakeOutbound({content: this._createMessage()});
|
|
349
368
|
};
|
|
350
369
|
|
|
351
|
-
|
|
370
|
+
Activity.prototype.evaluateOutbound = function evaluateOutbound(fromMessage, discardRestAtTake, callback) {
|
|
352
371
|
return this[kFlows].outboundEvaluator.evaluate(fromMessage, discardRestAtTake, callback);
|
|
353
372
|
};
|
|
354
373
|
|
|
355
|
-
|
|
374
|
+
Activity.prototype.getState = function getState() {
|
|
356
375
|
const msg = this._createMessage();
|
|
357
376
|
|
|
358
377
|
const exec = this[kExec];
|
|
@@ -367,17 +386,17 @@ proto.getState = function getState() {
|
|
|
367
386
|
};
|
|
368
387
|
};
|
|
369
388
|
|
|
370
|
-
|
|
389
|
+
Activity.prototype.getApi = function getApi(message) {
|
|
371
390
|
const execution = this[kExec].execution;
|
|
372
391
|
if (execution && !execution.completed) return execution.getApi(message);
|
|
373
392
|
return ActivityApi(this.broker, message || this[kStateMessage]);
|
|
374
393
|
};
|
|
375
394
|
|
|
376
|
-
|
|
395
|
+
Activity.prototype.getActivityById = function getActivityById(elementId) {
|
|
377
396
|
return this.context.getActivityById(elementId);
|
|
378
397
|
};
|
|
379
398
|
|
|
380
|
-
|
|
399
|
+
Activity.prototype._runDiscard = function runDiscard(discardContent) {
|
|
381
400
|
const exec = this[kExec];
|
|
382
401
|
const executionId = exec.executionId = exec.initExecutionId || getUniqueId(this.id);
|
|
383
402
|
exec.initExecutionId = null;
|
|
@@ -390,12 +409,13 @@ proto._runDiscard = function runDiscard(discardContent) {
|
|
|
390
409
|
this._consumeRunQ();
|
|
391
410
|
};
|
|
392
411
|
|
|
393
|
-
|
|
412
|
+
Activity.prototype._discardRun = function discardRun() {
|
|
394
413
|
const status = this.status;
|
|
395
414
|
if (!status) return;
|
|
396
415
|
|
|
397
416
|
const execution = this[kExec].execution;
|
|
398
417
|
if (execution && !execution.completed) return;
|
|
418
|
+
|
|
399
419
|
switch (status) {
|
|
400
420
|
case 'executing':
|
|
401
421
|
case 'error':
|
|
@@ -413,7 +433,7 @@ proto._discardRun = function discardRun() {
|
|
|
413
433
|
this._consumeRunQ();
|
|
414
434
|
};
|
|
415
435
|
|
|
416
|
-
|
|
436
|
+
Activity.prototype._shakeOutbound = function shakeOutbound(sourceMessage) {
|
|
417
437
|
const message = cloneMessage(sourceMessage);
|
|
418
438
|
message.content.sequence = message.content.sequence || [];
|
|
419
439
|
message.content.sequence.push({id: this.id, type: this.type});
|
|
@@ -428,7 +448,9 @@ proto._shakeOutbound = function shakeOutbound(sourceMessage) {
|
|
|
428
448
|
for (const flow of this[kFlows].outboundSequenceFlows) flow.shake(message);
|
|
429
449
|
};
|
|
430
450
|
|
|
431
|
-
|
|
451
|
+
Activity.prototype._consumeInbound = function consumeInbound() {
|
|
452
|
+
if (!this[kActivated]) return;
|
|
453
|
+
|
|
432
454
|
if (this.status) return;
|
|
433
455
|
const inboundQ = this.broker.getQueue('inbound-q');
|
|
434
456
|
if (this[kFlags].isParallelJoin) {
|
|
@@ -438,9 +460,8 @@ proto._consumeInbound = function consumeInbound() {
|
|
|
438
460
|
return inboundQ.consume(this[kMessageHandlers].onInbound, {consumerTag: '_run-on-inbound'});
|
|
439
461
|
};
|
|
440
462
|
|
|
441
|
-
|
|
463
|
+
Activity.prototype._onInbound = function onInbound(routingKey, message) {
|
|
442
464
|
message.ack();
|
|
443
|
-
const id = this.id;
|
|
444
465
|
const broker = this.broker;
|
|
445
466
|
broker.cancel('_run-on-inbound');
|
|
446
467
|
|
|
@@ -462,20 +483,10 @@ proto._onInbound = function onInbound(routingKey, message) {
|
|
|
462
483
|
if (content.discardSequence) discardSequence = content.discardSequence.slice();
|
|
463
484
|
return this._runDiscard({inbound, discardSequence});
|
|
464
485
|
}
|
|
465
|
-
case 'association.complete': {
|
|
466
|
-
broker.cancel('_run-on-inbound');
|
|
467
|
-
|
|
468
|
-
const compensationId = `${brokerSafeId(id)}_${brokerSafeId(content.sequenceId)}`;
|
|
469
|
-
this.logger.debug(`<${id}> completed compensation with id <${compensationId}>`);
|
|
470
|
-
|
|
471
|
-
return this._publishEvent('compensation.end', this._createMessage({
|
|
472
|
-
executionId: compensationId,
|
|
473
|
-
}));
|
|
474
|
-
}
|
|
475
486
|
}
|
|
476
487
|
};
|
|
477
488
|
|
|
478
|
-
|
|
489
|
+
Activity.prototype._onJoinInbound = function onJoinInbound(routingKey, message) {
|
|
479
490
|
const {content} = message;
|
|
480
491
|
const {inboundSequenceFlows, inboundJoinFlows, inboundTriggers} = this[kFlows];
|
|
481
492
|
const idx = inboundJoinFlows.findIndex((msg) => msg.content.id === content.id);
|
|
@@ -516,9 +527,8 @@ proto._onJoinInbound = function onJoinInbound(routingKey, message) {
|
|
|
516
527
|
return this.run({inbound});
|
|
517
528
|
};
|
|
518
529
|
|
|
519
|
-
|
|
530
|
+
Activity.prototype._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
520
531
|
const {fields, content, properties} = message;
|
|
521
|
-
const id = this.id;
|
|
522
532
|
const inboundQ = this.broker.getQueue('inbound-q');
|
|
523
533
|
|
|
524
534
|
switch (routingKey) {
|
|
@@ -536,36 +546,17 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
|
536
546
|
case 'flow.take':
|
|
537
547
|
case 'flow.discard':
|
|
538
548
|
return inboundQ.queueMessage(fields, cloneContent(content), properties);
|
|
539
|
-
case 'association.discard': {
|
|
540
|
-
this.logger.debug(`<${id}> compensation discarded`);
|
|
541
|
-
return inboundQ.purge();
|
|
542
|
-
}
|
|
543
|
-
case 'association.complete': {
|
|
544
|
-
if (!this[kFlags].isForCompensation) break;
|
|
545
|
-
|
|
546
|
-
inboundQ.queueMessage(fields, cloneContent(content), properties);
|
|
547
|
-
|
|
548
|
-
const compensationId = `${brokerSafeId(id)}_${brokerSafeId(content.sequenceId)}`;
|
|
549
|
-
this._publishEvent('compensation.start', this._createMessage({
|
|
550
|
-
executionId: compensationId,
|
|
551
|
-
placeholder: true,
|
|
552
|
-
}));
|
|
553
|
-
|
|
554
|
-
this.logger.debug(`<${id}> start compensation with id <${compensationId}>`);
|
|
555
|
-
|
|
556
|
-
return this._consumeInbound();
|
|
557
|
-
}
|
|
558
549
|
}
|
|
559
550
|
};
|
|
560
551
|
|
|
561
|
-
|
|
552
|
+
Activity.prototype._consumeRunQ = function consumeRunQ() {
|
|
562
553
|
if (this[kConsuming]) return;
|
|
563
554
|
|
|
564
555
|
this[kConsuming] = true;
|
|
565
556
|
this.broker.getQueue('run-q').assertConsumer(this[kMessageHandlers].onRunMessage, {exclusive: true, consumerTag: '_activity-run'});
|
|
566
557
|
};
|
|
567
558
|
|
|
568
|
-
|
|
559
|
+
Activity.prototype._onRunMessage = function onRunMessage(routingKey, message, messageProperties) {
|
|
569
560
|
switch (routingKey) {
|
|
570
561
|
case 'run.outbound.discard':
|
|
571
562
|
case 'run.outbound.take':
|
|
@@ -586,7 +577,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message, messageProperti
|
|
|
586
577
|
});
|
|
587
578
|
};
|
|
588
579
|
|
|
589
|
-
|
|
580
|
+
Activity.prototype._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
590
581
|
const isRedelivered = message.fields.redelivered;
|
|
591
582
|
const content = cloneContent(message.content);
|
|
592
583
|
const correlationId = message.properties.correlationId;
|
|
@@ -633,6 +624,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
633
624
|
case 'run.execute.passthrough': {
|
|
634
625
|
const execution = this.execution;
|
|
635
626
|
if (!isRedelivered && execution) {
|
|
627
|
+
if (execution.completed) return message.ack();
|
|
636
628
|
this[kExecuteMessage] = message;
|
|
637
629
|
return execution.passthrough(message);
|
|
638
630
|
}
|
|
@@ -712,7 +704,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
712
704
|
if (!step) message.ack();
|
|
713
705
|
};
|
|
714
706
|
|
|
715
|
-
|
|
707
|
+
Activity.prototype._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
716
708
|
const executeMessage = this[kExecuteMessage];
|
|
717
709
|
const content = cloneContent({
|
|
718
710
|
...executeMessage.content,
|
|
@@ -741,6 +733,7 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
|
741
733
|
broker.publish('run', 'run.discarded', content, {correlationId});
|
|
742
734
|
break;
|
|
743
735
|
}
|
|
736
|
+
case 'execution.cancel':
|
|
744
737
|
case 'execution.discard':
|
|
745
738
|
this.status = 'discarded';
|
|
746
739
|
broker.publish('run', 'run.discarded', content, {correlationId});
|
|
@@ -755,14 +748,13 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
|
755
748
|
this._ackRunExecuteMessage();
|
|
756
749
|
};
|
|
757
750
|
|
|
758
|
-
|
|
751
|
+
Activity.prototype._ackRunExecuteMessage = function ackRunExecuteMessage() {
|
|
759
752
|
if (this.environment.settings.step) return;
|
|
760
753
|
const executeMessage = this[kExecuteMessage];
|
|
761
|
-
this[kExecuteMessage] = null;
|
|
762
754
|
executeMessage.ack();
|
|
763
755
|
};
|
|
764
756
|
|
|
765
|
-
|
|
757
|
+
Activity.prototype._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
|
|
766
758
|
const {content, properties} = message;
|
|
767
759
|
const correlationId = properties.correlationId;
|
|
768
760
|
if (content.ignoreOutbound) {
|
|
@@ -783,7 +775,7 @@ proto._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
|
|
|
783
775
|
});
|
|
784
776
|
};
|
|
785
777
|
|
|
786
|
-
|
|
778
|
+
Activity.prototype._doOutbound = function doOutbound(fromMessage, isDiscarded, callback) {
|
|
787
779
|
const outboundSequenceFlows = this[kFlows].outboundSequenceFlows;
|
|
788
780
|
if (!outboundSequenceFlows.length) return callback(null, []);
|
|
789
781
|
|
|
@@ -813,7 +805,7 @@ proto._doOutbound = function doOutbound(fromMessage, isDiscarded, callback) {
|
|
|
813
805
|
});
|
|
814
806
|
};
|
|
815
807
|
|
|
816
|
-
|
|
808
|
+
Activity.prototype._doRunOutbound = function doRunOutbound(outboundList, content, discardSequence) {
|
|
817
809
|
for (const outboundFlow of outboundList) {
|
|
818
810
|
const {id: flowId, action} = outboundFlow;
|
|
819
811
|
this.broker.publish('run', 'run.outbound.' + action, cloneContent(content, {
|
|
@@ -827,7 +819,7 @@ proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequ
|
|
|
827
819
|
return outboundList;
|
|
828
820
|
};
|
|
829
821
|
|
|
830
|
-
|
|
822
|
+
Activity.prototype._onResumeMessage = function onResumeMessage(message) {
|
|
831
823
|
message.ack();
|
|
832
824
|
|
|
833
825
|
const stateMessage = this[kStateMessage];
|
|
@@ -852,7 +844,7 @@ proto._onResumeMessage = function onResumeMessage(message) {
|
|
|
852
844
|
return this.broker.publish('run', fields.routingKey, cloneContent(stateMessage.content), stateMessage.properties);
|
|
853
845
|
};
|
|
854
846
|
|
|
855
|
-
|
|
847
|
+
Activity.prototype._publishEvent = function publishEvent(state, content, properties = {}) {
|
|
856
848
|
this.broker.publish('event', `activity.${state}`, cloneContent(content, {state}), {
|
|
857
849
|
...properties,
|
|
858
850
|
type: state,
|
|
@@ -861,7 +853,7 @@ proto._publishEvent = function publishEvent(state, content, properties = {}) {
|
|
|
861
853
|
});
|
|
862
854
|
};
|
|
863
855
|
|
|
864
|
-
|
|
856
|
+
Activity.prototype._onStop = function onStop(message) {
|
|
865
857
|
const running = this[kConsuming];
|
|
866
858
|
|
|
867
859
|
this.stopped = true;
|
|
@@ -880,7 +872,7 @@ proto._onStop = function onStop(message) {
|
|
|
880
872
|
}
|
|
881
873
|
};
|
|
882
874
|
|
|
883
|
-
|
|
875
|
+
Activity.prototype._consumeApi = function consumeApi() {
|
|
884
876
|
const executionId = this[kExec].executionId;
|
|
885
877
|
if (!executionId) return;
|
|
886
878
|
const broker = this.broker;
|
|
@@ -888,7 +880,7 @@ proto._consumeApi = function consumeApi() {
|
|
|
888
880
|
broker.subscribeTmp('api', `activity.*.${executionId}`, this[kMessageHandlers].onApiMessage, {noAck: true, consumerTag: '_activity-api', priority: 100});
|
|
889
881
|
};
|
|
890
882
|
|
|
891
|
-
|
|
883
|
+
Activity.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
892
884
|
switch (message.properties.type) {
|
|
893
885
|
case 'discard': {
|
|
894
886
|
return this._discardRun(message);
|
|
@@ -902,7 +894,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
902
894
|
}
|
|
903
895
|
};
|
|
904
896
|
|
|
905
|
-
|
|
897
|
+
Activity.prototype._createMessage = function createMessage(override) {
|
|
906
898
|
const name = this.name, status = this.status, parent = this.parent;
|
|
907
899
|
const result = {
|
|
908
900
|
...override,
|
|
@@ -920,11 +912,11 @@ proto._createMessage = function createMessage(override) {
|
|
|
920
912
|
return result;
|
|
921
913
|
};
|
|
922
914
|
|
|
923
|
-
|
|
915
|
+
Activity.prototype._getOutboundSequenceFlowById = function getOutboundSequenceFlowById(flowId) {
|
|
924
916
|
return this[kFlows].outboundSequenceFlows.find((flow) => flow.id === flowId);
|
|
925
917
|
};
|
|
926
918
|
|
|
927
|
-
|
|
919
|
+
Activity.prototype._deactivateRunConsumers = function _deactivateRunConsumers() {
|
|
928
920
|
const broker = this.broker;
|
|
929
921
|
broker.cancel('_activity-api');
|
|
930
922
|
broker.cancel('_activity-run');
|