bpmn-elements 6.0.1 → 8.0.1
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 +341 -0
- package/README.md +3 -0
- package/dist/index.js +52 -44
- package/dist/src/Api.js +77 -76
- package/dist/src/Context.js +176 -172
- package/dist/src/Environment.js +110 -102
- package/dist/src/EventBroker.js +89 -88
- package/dist/src/ExtensionsMapper.js +2 -2
- package/dist/src/MessageFormatter.js +164 -95
- package/dist/src/Scripts.js +6 -2
- package/dist/src/activity/Activity.js +1105 -916
- package/dist/src/activity/ActivityExecution.js +342 -297
- package/dist/src/activity/Dummy.js +3 -3
- package/dist/src/definition/Definition.js +498 -444
- package/dist/src/definition/DefinitionExecution.js +710 -408
- package/dist/src/error/Errors.js +17 -7
- package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
- package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
- package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
- package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
- package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
- package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
- package/dist/src/events/BoundaryEvent.js +180 -144
- package/dist/src/events/EndEvent.js +18 -23
- package/dist/src/events/IntermediateCatchEvent.js +44 -58
- package/dist/src/events/IntermediateThrowEvent.js +18 -23
- package/dist/src/events/StartEvent.js +109 -94
- package/dist/src/flows/Association.js +94 -100
- package/dist/src/flows/MessageFlow.js +86 -103
- package/dist/src/flows/SequenceFlow.js +173 -182
- package/dist/src/gateways/EventBasedGateway.js +88 -84
- package/dist/src/gateways/ExclusiveGateway.js +13 -16
- package/dist/src/gateways/InclusiveGateway.js +11 -14
- package/dist/src/gateways/ParallelGateway.js +11 -14
- package/dist/src/getPropertyValue.js +34 -34
- package/dist/src/io/BpmnIO.js +17 -14
- package/dist/src/io/EnvironmentDataObject.js +33 -29
- package/dist/src/io/EnvironmentDataStore.js +33 -29
- package/dist/src/io/EnvironmentDataStoreReference.js +35 -31
- package/dist/src/io/InputOutputSpecification.js +177 -168
- package/dist/src/io/Properties.js +117 -124
- package/dist/src/messageHelper.js +1 -1
- package/dist/src/process/Process.js +439 -362
- package/dist/src/process/ProcessExecution.js +748 -646
- package/dist/src/shared.js +2 -2
- package/dist/src/tasks/CallActivity.js +160 -0
- package/dist/src/tasks/LoopCharacteristics.js +309 -330
- package/dist/src/tasks/ReceiveTask.js +233 -182
- package/dist/src/tasks/ScriptTask.js +35 -41
- package/dist/src/tasks/ServiceImplementation.js +13 -20
- package/dist/src/tasks/ServiceTask.js +82 -75
- package/dist/src/tasks/SignalTask.js +97 -93
- package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/dist/src/tasks/SubProcess.js +193 -175
- package/dist/src/tasks/Task.js +17 -19
- package/index.js +2 -0
- package/package.json +16 -16
- package/src/Api.js +65 -59
- package/src/Context.js +145 -140
- package/src/Environment.js +116 -100
- package/src/EventBroker.js +67 -68
- package/src/ExtensionsMapper.js +2 -2
- package/src/MessageFormatter.js +132 -74
- package/src/activity/Activity.js +914 -776
- package/src/activity/ActivityExecution.js +293 -247
- package/src/activity/Dummy.js +2 -2
- package/src/definition/Definition.js +437 -401
- package/src/definition/DefinitionExecution.js +598 -340
- package/src/error/Errors.js +11 -6
- package/src/eventDefinitions/CancelEventDefinition.js +164 -121
- package/src/eventDefinitions/CompensateEventDefinition.js +159 -124
- package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
- package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
- package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
- package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
- package/src/eventDefinitions/LinkEventDefinition.js +160 -129
- package/src/eventDefinitions/MessageEventDefinition.js +178 -121
- package/src/eventDefinitions/SignalEventDefinition.js +162 -106
- package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
- package/src/eventDefinitions/TimerEventDefinition.js +202 -167
- package/src/events/BoundaryEvent.js +156 -115
- package/src/events/EndEvent.js +15 -18
- package/src/events/IntermediateCatchEvent.js +40 -44
- package/src/events/IntermediateThrowEvent.js +15 -18
- package/src/events/StartEvent.js +84 -50
- package/src/flows/Association.js +98 -112
- package/src/flows/MessageFlow.js +81 -97
- package/src/flows/SequenceFlow.js +146 -160
- package/src/gateways/EventBasedGateway.js +75 -68
- package/src/gateways/ExclusiveGateway.js +8 -13
- package/src/gateways/InclusiveGateway.js +8 -13
- package/src/gateways/ParallelGateway.js +8 -13
- package/src/getPropertyValue.js +34 -33
- package/src/io/BpmnIO.js +20 -15
- package/src/io/EnvironmentDataObject.js +29 -18
- package/src/io/EnvironmentDataStore.js +29 -18
- package/src/io/EnvironmentDataStoreReference.js +31 -20
- package/src/io/InputOutputSpecification.js +154 -157
- package/src/io/Properties.js +95 -97
- package/src/process/Process.js +378 -333
- package/src/process/ProcessExecution.js +603 -553
- package/src/tasks/CallActivity.js +130 -0
- package/src/tasks/LoopCharacteristics.js +290 -289
- package/src/tasks/ReceiveTask.js +174 -107
- package/src/tasks/ScriptTask.js +27 -30
- package/src/tasks/ServiceImplementation.js +13 -18
- package/src/tasks/ServiceTask.js +67 -60
- package/src/tasks/SignalTask.js +77 -52
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +184 -157
- package/src/tasks/Task.js +15 -19
|
@@ -20,79 +20,52 @@ var _messageHelper = require("../messageHelper");
|
|
|
20
20
|
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
|
|
23
|
+
const kConsuming = Symbol.for('consuming');
|
|
24
|
+
const kCounters = Symbol.for('counters');
|
|
25
|
+
const kExec = Symbol.for('execution');
|
|
26
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
27
|
+
const kMessageHandlers = Symbol.for('messageHandlers');
|
|
28
|
+
const kStateMessage = Symbol.for('stateMessage');
|
|
29
|
+
const kStatus = Symbol.for('status');
|
|
30
|
+
const kStopped = Symbol.for('stopped');
|
|
23
31
|
var _default = Definition;
|
|
24
32
|
exports.default = _default;
|
|
25
33
|
|
|
26
34
|
function Definition(context, options) {
|
|
35
|
+
if (!(this instanceof Definition)) return new Definition(context, options);
|
|
27
36
|
if (!context) throw new Error('No context');
|
|
28
37
|
const {
|
|
29
38
|
id,
|
|
30
39
|
name,
|
|
31
40
|
type = 'definition'
|
|
32
41
|
} = context;
|
|
33
|
-
|
|
42
|
+
this.id = id;
|
|
43
|
+
this.type = type;
|
|
44
|
+
this.name = name;
|
|
45
|
+
let environment;
|
|
34
46
|
|
|
35
47
|
if (options) {
|
|
36
|
-
environment = environment.clone(options);
|
|
37
|
-
context = context.clone(environment);
|
|
48
|
+
environment = this.environment = context.environment.clone(options);
|
|
49
|
+
this.context = context.clone(environment);
|
|
50
|
+
} else {
|
|
51
|
+
environment = this.environment = context.environment;
|
|
52
|
+
this.context = context;
|
|
38
53
|
}
|
|
39
54
|
|
|
40
|
-
|
|
41
|
-
let execution, executionId, processes, executableProcesses, postponedMessage, stateMessage, stopped, consumingRunQ;
|
|
42
|
-
let status;
|
|
43
|
-
let counters = {
|
|
55
|
+
this[kCounters] = {
|
|
44
56
|
completed: 0,
|
|
45
57
|
discarded: 0
|
|
46
58
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
get executionId() {
|
|
60
|
-
return executionId;
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
get status() {
|
|
64
|
-
return status;
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
get execution() {
|
|
68
|
-
return execution;
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
get isRunning() {
|
|
72
|
-
if (!consumingRunQ) return false;
|
|
73
|
-
return !!status;
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
get environment() {
|
|
77
|
-
return environment;
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
run,
|
|
81
|
-
getApi,
|
|
82
|
-
getState,
|
|
83
|
-
getActivityById,
|
|
84
|
-
getElementById,
|
|
85
|
-
getPostponed,
|
|
86
|
-
getProcesses,
|
|
87
|
-
getExecutableProcesses,
|
|
88
|
-
getProcessById,
|
|
89
|
-
sendMessage,
|
|
90
|
-
recover,
|
|
91
|
-
resume,
|
|
92
|
-
shake,
|
|
93
|
-
signal,
|
|
94
|
-
cancelActivity,
|
|
95
|
-
stop
|
|
59
|
+
this[kStopped] = false;
|
|
60
|
+
this[kExec] = {};
|
|
61
|
+
|
|
62
|
+
const onBrokerReturn = this._onBrokerReturnFn.bind(this);
|
|
63
|
+
|
|
64
|
+
this[kMessageHandlers] = {
|
|
65
|
+
onBrokerReturn,
|
|
66
|
+
onApiMessage: this._onApiMessage.bind(this),
|
|
67
|
+
onRunMessage: this._onRunMessage.bind(this),
|
|
68
|
+
onExecutionMessage: this._onExecutionMessage.bind(this)
|
|
96
69
|
};
|
|
97
70
|
const {
|
|
98
71
|
broker,
|
|
@@ -101,479 +74,560 @@ function Definition(context, options) {
|
|
|
101
74
|
waitFor,
|
|
102
75
|
emit,
|
|
103
76
|
emitFatal
|
|
104
|
-
} = (0, _EventBroker.DefinitionBroker)(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
function run(optionsOrCallback, optionalCallback) {
|
|
123
|
-
const [runOptions, callback] = (0, _shared.getOptionsAndCallback)(optionsOrCallback, optionalCallback);
|
|
77
|
+
} = (0, _EventBroker.DefinitionBroker)(this, onBrokerReturn);
|
|
78
|
+
this.broker = broker;
|
|
79
|
+
this.on = on;
|
|
80
|
+
this.once = once;
|
|
81
|
+
this.waitFor = waitFor;
|
|
82
|
+
this.emit = emit;
|
|
83
|
+
this.emitFatal = emitFatal;
|
|
84
|
+
this.logger = environment.Logger(type.toLowerCase());
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const proto = Definition.prototype;
|
|
88
|
+
Object.defineProperty(proto, 'counters', {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
|
|
91
|
+
get() {
|
|
92
|
+
return { ...this[kCounters]
|
|
93
|
+
};
|
|
94
|
+
}
|
|
124
95
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
throw err;
|
|
129
|
-
}
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(proto, 'execution', {
|
|
98
|
+
enumerable: true,
|
|
130
99
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const content = createMessage({ ...runOptions,
|
|
134
|
-
executionId
|
|
135
|
-
});
|
|
136
|
-
broker.publish('run', 'run.enter', content);
|
|
137
|
-
broker.publish('run', 'run.start', (0, _messageHelper.cloneContent)(content));
|
|
138
|
-
broker.publish('run', 'run.execute', (0, _messageHelper.cloneContent)(content));
|
|
139
|
-
logger.debug(`<${executionId} (${id})> run`);
|
|
140
|
-
activateRunConsumers();
|
|
141
|
-
return definitionApi;
|
|
100
|
+
get() {
|
|
101
|
+
return this[kExec].execution;
|
|
142
102
|
}
|
|
143
103
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (callback) return callback(err);
|
|
148
|
-
throw err;
|
|
149
|
-
}
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(proto, 'executionId', {
|
|
106
|
+
enumerable: true,
|
|
150
107
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
addConsumerCallbacks(callback);
|
|
154
|
-
logger.debug(`<${executionId} (${id})> resume`);
|
|
155
|
-
const content = createMessage({
|
|
156
|
-
executionId
|
|
157
|
-
});
|
|
158
|
-
broker.publish('run', 'run.resume', content, {
|
|
159
|
-
persistent: false
|
|
160
|
-
});
|
|
161
|
-
activateRunConsumers();
|
|
162
|
-
return definitionApi;
|
|
108
|
+
get() {
|
|
109
|
+
return this[kExec].executionId;
|
|
163
110
|
}
|
|
164
111
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
stopped = state.stopped;
|
|
169
|
-
status = state.status;
|
|
170
|
-
executionId = state.executionId;
|
|
171
|
-
|
|
172
|
-
if (state.counters) {
|
|
173
|
-
counters = { ...counters,
|
|
174
|
-
...state.counters
|
|
175
|
-
};
|
|
176
|
-
}
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(proto, 'isRunning', {
|
|
114
|
+
enumerable: true,
|
|
177
115
|
|
|
178
|
-
|
|
116
|
+
get() {
|
|
117
|
+
if (!this[kConsuming]) return false;
|
|
118
|
+
return !!this.status;
|
|
119
|
+
}
|
|
179
120
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(proto, 'status', {
|
|
123
|
+
enumerable: true,
|
|
183
124
|
|
|
184
|
-
|
|
185
|
-
return
|
|
125
|
+
get() {
|
|
126
|
+
return this[kStatus];
|
|
186
127
|
}
|
|
187
128
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(proto, 'stopped', {
|
|
131
|
+
enumerable: true,
|
|
191
132
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const bp = getProcessById(startActivity.parent.id);
|
|
196
|
-
if (!bp) return;
|
|
197
|
-
bps = [bp];
|
|
198
|
-
} else bps = getProcesses();
|
|
133
|
+
get() {
|
|
134
|
+
return this[kStopped];
|
|
135
|
+
}
|
|
199
136
|
|
|
200
|
-
|
|
201
|
-
return result;
|
|
137
|
+
});
|
|
202
138
|
|
|
203
|
-
|
|
204
|
-
|
|
139
|
+
proto.run = function run(optionsOrCallback, optionalCallback) {
|
|
140
|
+
const [runOptions, callback] = (0, _shared.getOptionsAndCallback)(optionsOrCallback, optionalCallback);
|
|
205
141
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
broker,
|
|
212
|
-
exchange: 'event'
|
|
213
|
-
});
|
|
214
|
-
}
|
|
142
|
+
if (this.isRunning) {
|
|
143
|
+
const err = new Error('definition is already running');
|
|
144
|
+
if (callback) return callback(err);
|
|
145
|
+
throw err;
|
|
146
|
+
}
|
|
215
147
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
result = { ...result,
|
|
219
|
-
...shakeResult
|
|
220
|
-
};
|
|
221
|
-
}
|
|
148
|
+
if (callback) {
|
|
149
|
+
addConsumerCallbacks(this, callback);
|
|
222
150
|
}
|
|
223
151
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
152
|
+
const exec = this[kExec];
|
|
153
|
+
exec.executionId = (0, _shared.getUniqueId)(this.id);
|
|
154
|
+
|
|
155
|
+
const content = this._createMessage({ ...runOptions
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const broker = this.broker;
|
|
159
|
+
broker.publish('run', 'run.enter', content);
|
|
160
|
+
broker.publish('run', 'run.start', (0, _messageHelper.cloneContent)(content));
|
|
161
|
+
broker.publish('run', 'run.execute', (0, _messageHelper.cloneContent)(content));
|
|
162
|
+
this.logger.debug(`<${this.executionId} (${this.id})> run`);
|
|
163
|
+
|
|
164
|
+
this._activateRunConsumers();
|
|
165
|
+
|
|
166
|
+
return this;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
proto.resume = function resume(callback) {
|
|
170
|
+
if (this.isRunning) {
|
|
171
|
+
const err = new Error('cannot resume running definition');
|
|
172
|
+
if (callback) return callback(err);
|
|
173
|
+
throw err;
|
|
234
174
|
}
|
|
235
175
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
176
|
+
this[kStopped] = false;
|
|
177
|
+
if (!this.status) return this;
|
|
178
|
+
|
|
179
|
+
if (callback) {
|
|
180
|
+
addConsumerCallbacks(this, callback);
|
|
241
181
|
}
|
|
242
182
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
183
|
+
this.logger.debug(`<${this.executionId} (${this.id})> resume`);
|
|
184
|
+
|
|
185
|
+
const content = this._createMessage();
|
|
186
|
+
|
|
187
|
+
this.broker.publish('run', 'run.resume', content, {
|
|
188
|
+
persistent: false
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
this._activateRunConsumers();
|
|
192
|
+
|
|
193
|
+
return this;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
proto.recover = function recover(state) {
|
|
197
|
+
if (this.isRunning) throw new Error('cannot recover running definition');
|
|
198
|
+
if (!state) return this;
|
|
199
|
+
this[kStopped] = !!state.stopped;
|
|
200
|
+
this[kStatus] = state.status;
|
|
201
|
+
const exec = this[kExec];
|
|
202
|
+
exec.executionId = state.executionId;
|
|
203
|
+
|
|
204
|
+
if (state.counters) {
|
|
205
|
+
this[kCounters] = { ...this[kCounters],
|
|
206
|
+
...state.counters
|
|
207
|
+
};
|
|
246
208
|
}
|
|
247
209
|
|
|
248
|
-
|
|
249
|
-
if (!callback) return;
|
|
250
|
-
broker.off('return', onBrokerReturn);
|
|
251
|
-
clearConsumers();
|
|
252
|
-
broker.subscribeOnce('event', 'definition.stop', cbLeave, {
|
|
253
|
-
consumerTag: '_definition-callback-stop'
|
|
254
|
-
});
|
|
255
|
-
broker.subscribeOnce('event', 'definition.leave', cbLeave, {
|
|
256
|
-
consumerTag: '_definition-callback-leave'
|
|
257
|
-
});
|
|
258
|
-
broker.subscribeOnce('event', 'definition.error', cbError, {
|
|
259
|
-
consumerTag: '_definition-callback-error'
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
function cbLeave(_, message) {
|
|
263
|
-
clearConsumers();
|
|
264
|
-
return callback(null, getApi(message));
|
|
265
|
-
}
|
|
210
|
+
this.environment.recover(state.environment);
|
|
266
211
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const err = (0, _Errors.makeErrorFromMessage)(message);
|
|
271
|
-
return callback(err);
|
|
272
|
-
}
|
|
212
|
+
if (state.execution) {
|
|
213
|
+
exec.execution = new _DefinitionExecution.default(this, this.context).recover(state.execution);
|
|
214
|
+
}
|
|
273
215
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
216
|
+
this.broker.recover(state.broker);
|
|
217
|
+
return this;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
proto.shake = function shake(startId) {
|
|
221
|
+
let result = {};
|
|
222
|
+
const broker = this.broker;
|
|
223
|
+
let bps;
|
|
224
|
+
|
|
225
|
+
if (startId) {
|
|
226
|
+
const startActivity = this.getActivityById(startId);
|
|
227
|
+
if (!startActivity) return;
|
|
228
|
+
const bp = this.getProcessById(startActivity.parent.id);
|
|
229
|
+
if (!bp) return;
|
|
230
|
+
bps = [bp];
|
|
231
|
+
} else bps = this.getProcesses();
|
|
232
|
+
|
|
233
|
+
bps.forEach(shakeProcess);
|
|
234
|
+
return result;
|
|
235
|
+
|
|
236
|
+
function shakeProcess(shakeBp) {
|
|
237
|
+
let shovel;
|
|
238
|
+
|
|
239
|
+
if (!shakeBp.isRunning) {
|
|
240
|
+
shovel = shakeBp.broker.createShovel('shaker', {
|
|
241
|
+
exchange: 'event',
|
|
242
|
+
pattern: '*.shake#'
|
|
243
|
+
}, {
|
|
244
|
+
broker,
|
|
245
|
+
exchange: 'event'
|
|
246
|
+
});
|
|
279
247
|
}
|
|
248
|
+
|
|
249
|
+
const shakeResult = shakeBp.shake(startId);
|
|
250
|
+
if (shovel) shakeBp.broker.closeShovel('shaker');
|
|
251
|
+
result = { ...result,
|
|
252
|
+
...shakeResult
|
|
253
|
+
};
|
|
280
254
|
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
proto.getState = function getState() {
|
|
258
|
+
return this._createMessage({
|
|
259
|
+
status: this.status,
|
|
260
|
+
stopped: this.stopped,
|
|
261
|
+
counters: this.counters,
|
|
262
|
+
environment: this.environment.getState(),
|
|
263
|
+
execution: this.execution && this.execution.getState(),
|
|
264
|
+
broker: this.broker.getState(true)
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
proto.getProcesses = function getProcesses() {
|
|
269
|
+
const execution = this.execution;
|
|
270
|
+
if (execution) return execution.getProcesses();
|
|
271
|
+
return this.context.getProcesses();
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
proto.getExecutableProcesses = function getExecutableProcesses() {
|
|
275
|
+
const execution = this.execution;
|
|
276
|
+
if (execution) return execution.getExecutableProcesses();
|
|
277
|
+
return this.context.getExecutableProcesses();
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
proto.getRunningProcesses = function getRunningProcesses() {
|
|
281
|
+
const execution = this.execution;
|
|
282
|
+
if (!execution) return [];
|
|
283
|
+
return execution.getRunningProcesses();
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
proto.getProcessById = function getProcessById(processId) {
|
|
287
|
+
return this.getProcesses().find(p => p.id === processId);
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
proto.getActivityById = function getActivityById(childId) {
|
|
291
|
+
const bps = this.getProcesses();
|
|
292
|
+
|
|
293
|
+
for (const bp of bps) {
|
|
294
|
+
const child = bp.getActivityById(childId);
|
|
295
|
+
if (child) return child;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return null;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
proto.getElementById = function getElementById(elementId) {
|
|
302
|
+
return this.context.getActivityById(elementId);
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
proto.getPostponed = function getPostponed(...args) {
|
|
306
|
+
const execution = this.execution;
|
|
307
|
+
if (!execution) return [];
|
|
308
|
+
return execution.getPostponed(...args);
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
proto.getApi = function getApi(message) {
|
|
312
|
+
const execution = this.execution;
|
|
313
|
+
if (execution) return execution.getApi(message);
|
|
314
|
+
message = message || this[kStateMessage];
|
|
315
|
+
if (!message) throw new Error('Definition is not running');
|
|
316
|
+
return (0, _Api.DefinitionApi)(this.broker, message);
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
proto.signal = function signal(message) {
|
|
320
|
+
return this.getApi().signal(message, {
|
|
321
|
+
delegate: true
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
proto.cancelActivity = function cancelActivity(message) {
|
|
326
|
+
return this.getApi().cancel(message, {
|
|
327
|
+
delegate: true
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
proto.sendMessage = function sendMessage(message) {
|
|
332
|
+
const messageContent = {
|
|
333
|
+
message
|
|
334
|
+
};
|
|
335
|
+
let messageType = 'message';
|
|
336
|
+
const reference = message && message.id && this.getElementById(message.id);
|
|
281
337
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
338
|
+
if (reference && reference.resolve) {
|
|
339
|
+
const resolvedReference = reference.resolve(this._createMessage({
|
|
340
|
+
message
|
|
341
|
+
}));
|
|
342
|
+
messageType = resolvedReference.messageType || messageType;
|
|
343
|
+
messageContent.message = { ...message,
|
|
344
|
+
...resolvedReference
|
|
288
345
|
};
|
|
289
346
|
}
|
|
290
347
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
348
|
+
return this.getApi().sendApiMessage(messageType, messageContent, {
|
|
349
|
+
delegate: true
|
|
350
|
+
});
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
proto.stop = function stop() {
|
|
354
|
+
if (!this.isRunning) return;
|
|
355
|
+
this.getApi().stop();
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
proto._activateRunConsumers = function activateRunConsumers() {
|
|
359
|
+
this[kConsuming] = true;
|
|
360
|
+
const broker = this.broker;
|
|
361
|
+
const {
|
|
362
|
+
onApiMessage,
|
|
363
|
+
onRunMessage
|
|
364
|
+
} = this[kMessageHandlers];
|
|
365
|
+
broker.subscribeTmp('api', `definition.*.${this.executionId}`, onApiMessage, {
|
|
366
|
+
noAck: true,
|
|
367
|
+
consumerTag: '_definition-api'
|
|
368
|
+
});
|
|
369
|
+
broker.getQueue('run-q').assertConsumer(onRunMessage, {
|
|
370
|
+
exclusive: true,
|
|
371
|
+
consumerTag: '_definition-run'
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
proto._deactivateRunConsumers = function deactivateRunConsumers() {
|
|
376
|
+
const broker = this.broker;
|
|
377
|
+
broker.cancel('_definition-api');
|
|
378
|
+
broker.cancel('_definition-run');
|
|
379
|
+
broker.cancel('_definition-execution');
|
|
380
|
+
this[kConsuming] = false;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
proto._createMessage = function createMessage(override) {
|
|
384
|
+
return {
|
|
385
|
+
id: this.id,
|
|
386
|
+
type: this.type,
|
|
387
|
+
name: this.name,
|
|
388
|
+
executionId: this.executionId,
|
|
389
|
+
...override
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
394
|
+
const {
|
|
395
|
+
content,
|
|
396
|
+
fields
|
|
397
|
+
} = message;
|
|
398
|
+
|
|
399
|
+
if (routingKey === 'run.resume') {
|
|
400
|
+
return this._onResumeMessage(message);
|
|
297
401
|
}
|
|
298
402
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
content,
|
|
302
|
-
ack,
|
|
303
|
-
fields
|
|
304
|
-
} = message;
|
|
403
|
+
const exec = this[kExec];
|
|
404
|
+
this[kStateMessage] = message;
|
|
305
405
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
406
|
+
switch (routingKey) {
|
|
407
|
+
case 'run.enter':
|
|
408
|
+
{
|
|
409
|
+
this.logger.debug(`<${this.executionId} (${this.id})> enter`);
|
|
410
|
+
this[kStatus] = 'entered';
|
|
411
|
+
if (fields.redelivered) break;
|
|
412
|
+
exec.execution = undefined;
|
|
309
413
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
switch (routingKey) {
|
|
313
|
-
case 'run.enter':
|
|
314
|
-
{
|
|
315
|
-
logger.debug(`<${executionId} (${id})> enter`);
|
|
316
|
-
status = 'entered';
|
|
317
|
-
if (fields.redelivered) break;
|
|
318
|
-
execution = undefined;
|
|
319
|
-
publishEvent('enter', content);
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
414
|
+
this._publishEvent('enter', content);
|
|
322
415
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
logger.debug(`<${executionId} (${id})> start`);
|
|
326
|
-
status = 'start';
|
|
327
|
-
publishEvent('start', content);
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
330
418
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
419
|
+
case 'run.start':
|
|
420
|
+
{
|
|
421
|
+
this.logger.debug(`<${this.executionId} (${this.id})> start`);
|
|
422
|
+
this[kStatus] = 'start';
|
|
335
423
|
|
|
336
|
-
|
|
337
|
-
executeMessage.fields.redelivered = undefined;
|
|
338
|
-
}
|
|
424
|
+
this._publishEvent('start', content);
|
|
339
425
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
exclusive: true,
|
|
343
|
-
consumerTag: '_definition-execution'
|
|
344
|
-
});
|
|
345
|
-
execution = execution || (0, _DefinitionExecution.default)(definitionApi, context);
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
346
428
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
429
|
+
case 'run.execute':
|
|
430
|
+
{
|
|
431
|
+
this[kStatus] = 'executing';
|
|
432
|
+
const executeMessage = (0, _messageHelper.cloneMessage)(message);
|
|
350
433
|
|
|
351
|
-
|
|
434
|
+
if (fields.redelivered && !exec.execution) {
|
|
435
|
+
executeMessage.fields.redelivered = undefined;
|
|
352
436
|
}
|
|
353
437
|
|
|
354
|
-
|
|
355
|
-
{
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
broker.publish('run', 'run.leave', content);
|
|
361
|
-
publishEvent('end', content);
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
438
|
+
this[kExecuteMessage] = message;
|
|
439
|
+
this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {
|
|
440
|
+
exclusive: true,
|
|
441
|
+
consumerTag: '_definition-execution'
|
|
442
|
+
});
|
|
443
|
+
exec.execution = exec.execution || new _DefinitionExecution.default(this, this.context);
|
|
364
444
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (status === 'discarded') break;
|
|
368
|
-
counters.discarded++;
|
|
369
|
-
status = 'discarded';
|
|
370
|
-
broker.publish('run', 'run.leave', content);
|
|
371
|
-
break;
|
|
445
|
+
if (executeMessage.fields.redelivered) {
|
|
446
|
+
this._publishEvent('resume', content);
|
|
372
447
|
}
|
|
373
448
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
publishEvent('error', (0, _messageHelper.cloneContent)(content, {
|
|
377
|
-
error: fields.redelivered ? (0, _Errors.makeErrorFromMessage)(message) : content.error
|
|
378
|
-
}), {
|
|
379
|
-
mandatory: true
|
|
380
|
-
});
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
449
|
+
return exec.execution.execute(executeMessage);
|
|
450
|
+
}
|
|
383
451
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
}
|
|
452
|
+
case 'run.end':
|
|
453
|
+
{
|
|
454
|
+
if (this[kStatus] === 'end') break;
|
|
455
|
+
this[kCounters].completed++;
|
|
456
|
+
this.logger.debug(`<${this.executionId} (${this.id})> completed`);
|
|
457
|
+
this[kStatus] = 'end';
|
|
458
|
+
this.broker.publish('run', 'run.leave', content);
|
|
393
459
|
|
|
394
|
-
|
|
460
|
+
this._publishEvent('end', content);
|
|
395
461
|
|
|
396
|
-
|
|
397
|
-
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
398
464
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
465
|
+
case 'run.error':
|
|
466
|
+
{
|
|
467
|
+
this._publishEvent('error', { ...content,
|
|
468
|
+
error: fields.redelivered ? (0, _Errors.makeErrorFromMessage)(message) : content.error
|
|
469
|
+
}, {
|
|
470
|
+
mandatory: true
|
|
471
|
+
});
|
|
406
472
|
|
|
407
|
-
|
|
408
|
-
return;
|
|
473
|
+
break;
|
|
409
474
|
}
|
|
410
475
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
476
|
+
case 'run.discarded':
|
|
477
|
+
{
|
|
478
|
+
if (this[kStatus] === 'discarded') break;
|
|
479
|
+
this[kCounters].discarded++;
|
|
480
|
+
this[kStatus] = 'discarded';
|
|
481
|
+
this.broker.publish('run', 'run.leave', content);
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
416
484
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
} = message;
|
|
422
|
-
const messageType = properties.type;
|
|
423
|
-
message.ack();
|
|
424
|
-
|
|
425
|
-
switch (messageType) {
|
|
426
|
-
case 'stopped':
|
|
427
|
-
{
|
|
428
|
-
deactivateRunConsumers();
|
|
429
|
-
return publishEvent('stop');
|
|
430
|
-
}
|
|
485
|
+
case 'run.leave':
|
|
486
|
+
{
|
|
487
|
+
message.ack();
|
|
488
|
+
this[kStatus] = undefined;
|
|
431
489
|
|
|
432
|
-
|
|
433
|
-
{
|
|
434
|
-
broker.publish('run', 'run.error', content);
|
|
435
|
-
broker.publish('run', 'run.discarded', content);
|
|
436
|
-
break;
|
|
437
|
-
}
|
|
490
|
+
this._deactivateRunConsumers();
|
|
438
491
|
|
|
439
|
-
|
|
440
|
-
{
|
|
441
|
-
broker.publish('run', 'run.end', content);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
492
|
+
this._publishEvent('leave', this._createMessage());
|
|
444
493
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
postponedMessage = null;
|
|
448
|
-
ackMessage.ack();
|
|
449
|
-
}
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
450
496
|
}
|
|
451
497
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
type: action,
|
|
455
|
-
...msgOpts
|
|
456
|
-
});
|
|
457
|
-
}
|
|
498
|
+
message.ack();
|
|
499
|
+
};
|
|
458
500
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
status,
|
|
463
|
-
stopped,
|
|
464
|
-
counters: { ...counters
|
|
465
|
-
},
|
|
466
|
-
environment: environment.getState(),
|
|
467
|
-
execution: execution && execution.getState(),
|
|
468
|
-
broker: broker.getState(true)
|
|
469
|
-
});
|
|
470
|
-
}
|
|
501
|
+
proto._onResumeMessage = function onResumeMessage(message) {
|
|
502
|
+
message.ack();
|
|
503
|
+
const stateMessage = this[kStateMessage];
|
|
471
504
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
505
|
+
switch (stateMessage.fields.routingKey) {
|
|
506
|
+
case 'run.discarded':
|
|
507
|
+
case 'run.end':
|
|
508
|
+
case 'run.leave':
|
|
509
|
+
break;
|
|
476
510
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
return executableProcesses;
|
|
511
|
+
default:
|
|
512
|
+
return;
|
|
480
513
|
}
|
|
481
514
|
|
|
482
|
-
|
|
483
|
-
return getProcesses().find(p => p.id === processId);
|
|
484
|
-
}
|
|
515
|
+
if (!stateMessage.fields.redelivered) return;
|
|
485
516
|
|
|
486
|
-
|
|
487
|
-
if (processes) return processes;
|
|
488
|
-
executableProcesses = context.getExecutableProcesses() || [];
|
|
489
|
-
processes = context.getProcesses() || [];
|
|
490
|
-
logger.debug(`<${id}> found ${processes.length} processes`);
|
|
491
|
-
}
|
|
517
|
+
this._debug(`resume from ${this.status}`);
|
|
492
518
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
const siblings = getProcesses();
|
|
519
|
+
return this.broker.publish('run', stateMessage.fields.routingKey, (0, _messageHelper.cloneContent)(stateMessage.content), stateMessage.properties);
|
|
520
|
+
};
|
|
496
521
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
522
|
+
proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
523
|
+
const {
|
|
524
|
+
content,
|
|
525
|
+
properties
|
|
526
|
+
} = message;
|
|
527
|
+
const messageType = properties.type;
|
|
528
|
+
message.ack();
|
|
529
|
+
|
|
530
|
+
switch (messageType) {
|
|
531
|
+
case 'stopped':
|
|
532
|
+
{
|
|
533
|
+
return this._onStop();
|
|
534
|
+
}
|
|
501
535
|
|
|
502
|
-
|
|
503
|
-
|
|
536
|
+
case 'error':
|
|
537
|
+
{
|
|
538
|
+
this.broker.publish('run', 'run.error', content);
|
|
539
|
+
this.broker.publish('run', 'run.discarded', content);
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
504
542
|
|
|
505
|
-
|
|
506
|
-
|
|
543
|
+
default:
|
|
544
|
+
{
|
|
545
|
+
this.broker.publish('run', 'run.end', content);
|
|
546
|
+
}
|
|
507
547
|
}
|
|
508
548
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
549
|
+
const executeMessage = this[kExecuteMessage];
|
|
550
|
+
this[kExecuteMessage] = null;
|
|
551
|
+
executeMessage.ack();
|
|
552
|
+
};
|
|
513
553
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
return (0, _Api.DefinitionApi)(broker, message || stateMessage);
|
|
518
|
-
}
|
|
554
|
+
proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
555
|
+
if (message.properties.type === 'stop') {
|
|
556
|
+
const execution = this.execution;
|
|
519
557
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
});
|
|
558
|
+
if (!execution || execution.completed) {
|
|
559
|
+
this._onStop();
|
|
560
|
+
}
|
|
524
561
|
}
|
|
562
|
+
};
|
|
525
563
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
564
|
+
proto._publishEvent = function publishEvent(action, content, msgOpts) {
|
|
565
|
+
const execution = this.execution;
|
|
566
|
+
this.broker.publish('event', `definition.${action}`, execution ? execution._createMessage(content) : (0, _messageHelper.cloneContent)(content), {
|
|
567
|
+
type: action,
|
|
568
|
+
...msgOpts
|
|
569
|
+
});
|
|
570
|
+
};
|
|
531
571
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
let messageType = 'message';
|
|
537
|
-
const reference = message && message.id && getElementById(message.id);
|
|
538
|
-
|
|
539
|
-
if (reference && reference.resolve) {
|
|
540
|
-
const resolvedReference = reference.resolve(createMessage({
|
|
541
|
-
message
|
|
542
|
-
}));
|
|
543
|
-
messageType = resolvedReference.messageType || messageType;
|
|
544
|
-
messageContent.message = { ...message,
|
|
545
|
-
...resolvedReference
|
|
546
|
-
};
|
|
547
|
-
}
|
|
572
|
+
proto._onStop = function onStop() {
|
|
573
|
+
this[kStopped] = true;
|
|
574
|
+
|
|
575
|
+
this._deactivateRunConsumers();
|
|
548
576
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
577
|
+
return this._publishEvent('stop', this._createMessage());
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
proto._onBrokerReturnFn = function onBrokerReturn(message) {
|
|
581
|
+
if (message.properties.type === 'error') {
|
|
582
|
+
this._deactivateRunConsumers();
|
|
583
|
+
|
|
584
|
+
const err = (0, _Errors.makeErrorFromMessage)(message);
|
|
585
|
+
throw err;
|
|
552
586
|
}
|
|
587
|
+
};
|
|
553
588
|
|
|
554
|
-
|
|
555
|
-
|
|
589
|
+
proto._reset = function reset() {
|
|
590
|
+
this[kExec].executionId = undefined;
|
|
556
591
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
592
|
+
this._deactivateRunConsumers();
|
|
593
|
+
|
|
594
|
+
this.broker.purgeQueue('run-q');
|
|
595
|
+
this.broker.purgeQueue('execution-q');
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
proto._debug = function debug(msg) {
|
|
599
|
+
this.logger.debug(`<${this.id}> ${msg}`);
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
function addConsumerCallbacks(definition, callback) {
|
|
603
|
+
const broker = definition.broker;
|
|
604
|
+
clearConsumers();
|
|
605
|
+
broker.subscribeOnce('event', 'definition.stop', cbLeave, {
|
|
606
|
+
consumerTag: '_definition-callback-stop'
|
|
607
|
+
});
|
|
608
|
+
broker.subscribeOnce('event', 'definition.leave', cbLeave, {
|
|
609
|
+
consumerTag: '_definition-callback-leave'
|
|
610
|
+
});
|
|
611
|
+
broker.subscribeOnce('event', 'definition.error', cbError, {
|
|
612
|
+
consumerTag: '_definition-callback-error'
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
function cbLeave(_, message) {
|
|
616
|
+
clearConsumers();
|
|
617
|
+
return callback(null, definition.getApi(message));
|
|
565
618
|
}
|
|
566
619
|
|
|
567
|
-
function
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
620
|
+
function cbError(_, message) {
|
|
621
|
+
clearConsumers();
|
|
622
|
+
|
|
623
|
+
definition._reset();
|
|
624
|
+
|
|
625
|
+
return callback((0, _Errors.makeErrorFromMessage)(message));
|
|
571
626
|
}
|
|
572
627
|
|
|
573
|
-
function
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
executionQ.purge();
|
|
628
|
+
function clearConsumers() {
|
|
629
|
+
broker.cancel('_definition-callback-stop');
|
|
630
|
+
broker.cancel('_definition-callback-leave');
|
|
631
|
+
broker.cancel('_definition-callback-error');
|
|
578
632
|
}
|
|
579
633
|
}
|