bpmn-elements 7.0.0 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/src/Context.js +50 -40
- package/dist/src/Environment.js +39 -19
- package/dist/src/MessageFormatter.js +11 -11
- package/dist/src/activity/Activity.js +106 -106
- package/dist/src/activity/ActivityExecution.js +37 -37
- package/dist/src/activity/Message.js +2 -2
- package/dist/src/activity/Signal.js +2 -2
- package/dist/src/definition/Definition.js +50 -50
- package/dist/src/definition/DefinitionExecution.js +114 -125
- package/dist/src/eventDefinitions/CancelEventDefinition.js +16 -16
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +24 -24
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +26 -26
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +20 -20
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +14 -14
- package/dist/src/eventDefinitions/LinkEventDefinition.js +15 -15
- package/dist/src/eventDefinitions/MessageEventDefinition.js +23 -23
- package/dist/src/eventDefinitions/SignalEventDefinition.js +24 -24
- package/dist/src/eventDefinitions/TimerEventDefinition.js +76 -53
- package/dist/src/events/BoundaryEvent.js +67 -38
- package/dist/src/events/EndEvent.js +3 -3
- package/dist/src/events/IntermediateCatchEvent.js +3 -3
- package/dist/src/events/IntermediateThrowEvent.js +3 -3
- package/dist/src/events/StartEvent.js +9 -9
- package/dist/src/flows/Association.js +7 -7
- package/dist/src/flows/MessageFlow.js +9 -9
- package/dist/src/flows/SequenceFlow.js +7 -7
- package/dist/src/gateways/EventBasedGateway.js +11 -11
- package/dist/src/io/InputOutputSpecification.js +4 -4
- package/dist/src/io/Properties.js +9 -9
- package/dist/src/process/Process.js +64 -61
- package/dist/src/process/ProcessExecution.js +93 -90
- package/dist/src/tasks/ReceiveTask.js +16 -16
- package/dist/src/tasks/SubProcess.js +16 -18
- package/package.json +15 -16
- package/src/Context.js +48 -40
- package/src/Environment.js +48 -20
- package/src/EventBroker.js +1 -1
- package/src/MessageFormatter.js +11 -11
- package/src/activity/Activity.js +99 -100
- package/src/activity/ActivityExecution.js +35 -35
- package/src/activity/Message.js +1 -1
- package/src/activity/Signal.js +1 -1
- package/src/definition/Definition.js +51 -50
- package/src/definition/DefinitionExecution.js +111 -113
- package/src/eventDefinitions/CancelEventDefinition.js +16 -16
- package/src/eventDefinitions/CompensateEventDefinition.js +25 -24
- package/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
- package/src/eventDefinitions/ErrorEventDefinition.js +26 -26
- package/src/eventDefinitions/EscalationEventDefinition.js +20 -20
- package/src/eventDefinitions/EventDefinitionExecution.js +14 -14
- package/src/eventDefinitions/LinkEventDefinition.js +15 -15
- package/src/eventDefinitions/MessageEventDefinition.js +23 -23
- package/src/eventDefinitions/SignalEventDefinition.js +24 -24
- package/src/eventDefinitions/TimerEventDefinition.js +61 -44
- package/src/events/BoundaryEvent.js +53 -36
- package/src/events/EndEvent.js +3 -3
- package/src/events/IntermediateCatchEvent.js +3 -3
- package/src/events/IntermediateThrowEvent.js +3 -3
- package/src/events/StartEvent.js +9 -9
- package/src/flows/Association.js +7 -7
- package/src/flows/MessageFlow.js +9 -9
- package/src/flows/SequenceFlow.js +7 -7
- package/src/gateways/EventBasedGateway.js +11 -11
- package/src/io/BpmnIO.js +5 -1
- package/src/io/InputOutputSpecification.js +4 -4
- package/src/io/Properties.js +9 -9
- package/src/process/Process.js +62 -58
- package/src/process/ProcessExecution.js +86 -88
- package/src/tasks/ReceiveTask.js +16 -16
- package/src/tasks/SubProcess.js +16 -16
|
@@ -9,11 +9,11 @@ var _shared = require("../shared");
|
|
|
9
9
|
|
|
10
10
|
var _messageHelper = require("../messageHelper");
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
12
|
+
const kCompleted = Symbol.for('completed');
|
|
13
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
14
|
+
const kMessageQ = Symbol.for('messageQ');
|
|
15
|
+
const kCompensateQ = Symbol.for('compensateQ');
|
|
16
|
+
const kAssociations = Symbol.for('associations');
|
|
17
17
|
|
|
18
18
|
function CompensateEventDefinition(activity, eventDefinition, context) {
|
|
19
19
|
const {
|
|
@@ -33,10 +33,10 @@ function CompensateEventDefinition(activity, eventDefinition, context) {
|
|
|
33
33
|
this.logger = environment.Logger(type.toLowerCase());
|
|
34
34
|
|
|
35
35
|
if (!isThrowing) {
|
|
36
|
-
this[
|
|
37
|
-
this[
|
|
36
|
+
this[kCompleted] = false;
|
|
37
|
+
this[kAssociations] = context.getOutboundAssociations(id) || [];
|
|
38
38
|
const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-q`;
|
|
39
|
-
this[
|
|
39
|
+
this[kMessageQ] = broker.assertQueue(messageQueueName, {
|
|
40
40
|
autoDelete: false,
|
|
41
41
|
durable: true
|
|
42
42
|
});
|
|
@@ -50,7 +50,7 @@ function CompensateEventDefinition(activity, eventDefinition, context) {
|
|
|
50
50
|
const proto = CompensateEventDefinition.prototype;
|
|
51
51
|
Object.defineProperty(proto, 'executionId', {
|
|
52
52
|
get() {
|
|
53
|
-
const message = this[
|
|
53
|
+
const message = this[kExecuteMessage];
|
|
54
54
|
return message && message.content.executionId;
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -61,8 +61,8 @@ proto.execute = function execute(executeMessage) {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
proto.executeCatch = function executeCatch(executeMessage) {
|
|
64
|
-
this[
|
|
65
|
-
this[
|
|
64
|
+
this[kExecuteMessage] = executeMessage;
|
|
65
|
+
this[kCompleted] = false;
|
|
66
66
|
const executeContent = executeMessage.content;
|
|
67
67
|
const {
|
|
68
68
|
executionId,
|
|
@@ -73,7 +73,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
|
|
|
73
73
|
|
|
74
74
|
const broker = this.broker;
|
|
75
75
|
broker.assertExchange('compensate', 'topic');
|
|
76
|
-
this[
|
|
76
|
+
this[kCompensateQ] = broker.assertQueue('compensate-q', {
|
|
77
77
|
durable: true,
|
|
78
78
|
autoDelete: false
|
|
79
79
|
});
|
|
@@ -85,11 +85,11 @@ proto.executeCatch = function executeCatch(executeMessage) {
|
|
|
85
85
|
sourceExchange: 'execution',
|
|
86
86
|
bindExchange: 'compensate'
|
|
87
87
|
}));
|
|
88
|
-
this[
|
|
88
|
+
this[kMessageQ].consume(this._onCompensateApiMessage.bind(this), {
|
|
89
89
|
noAck: true,
|
|
90
90
|
consumerTag: `_oncompensate-${executionId}`
|
|
91
91
|
});
|
|
92
|
-
if (this[
|
|
92
|
+
if (this[kCompleted]) return;
|
|
93
93
|
|
|
94
94
|
const onApiMessage = this._onApiMessage.bind(this);
|
|
95
95
|
|
|
@@ -131,21 +131,21 @@ proto._onCollect = function onCollect(routingKey, message) {
|
|
|
131
131
|
case 'execute.error':
|
|
132
132
|
case 'execute.completed':
|
|
133
133
|
{
|
|
134
|
-
return this[
|
|
134
|
+
return this[kCompensateQ].queueMessage(message.fields, (0, _messageHelper.cloneContent)(message.content), message.properties);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, message) {
|
|
140
140
|
const output = message.content.message;
|
|
141
|
-
this[
|
|
141
|
+
this[kCompleted] = true;
|
|
142
142
|
|
|
143
143
|
this._stop();
|
|
144
144
|
|
|
145
145
|
this._debug('caught compensate event');
|
|
146
146
|
|
|
147
147
|
const broker = this.broker;
|
|
148
|
-
const executeContent = this[
|
|
148
|
+
const executeContent = this[kExecuteMessage].content;
|
|
149
149
|
const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
150
150
|
message: { ...output
|
|
151
151
|
},
|
|
@@ -155,14 +155,14 @@ proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, mess
|
|
|
155
155
|
broker.publish('event', 'activity.catch', catchContent, {
|
|
156
156
|
type: 'catch'
|
|
157
157
|
});
|
|
158
|
-
const compensateQ = this[
|
|
158
|
+
const compensateQ = this[kCompensateQ];
|
|
159
159
|
compensateQ.on('depleted', onDepleted);
|
|
160
160
|
compensateQ.consume(this._onCollected.bind(this), {
|
|
161
161
|
noAck: true,
|
|
162
162
|
consumerTag: '_convey-messages'
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
-
for (const association of this[
|
|
165
|
+
for (const association of this[kAssociations]) association.complete((0, _messageHelper.cloneMessage)(message));
|
|
166
166
|
|
|
167
167
|
function onDepleted() {
|
|
168
168
|
compensateQ.off('depleted', onDepleted);
|
|
@@ -174,7 +174,7 @@ proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, mess
|
|
|
174
174
|
};
|
|
175
175
|
|
|
176
176
|
proto._onCollected = function onCollected(routingKey, message) {
|
|
177
|
-
for (const association of this[
|
|
177
|
+
for (const association of this[kAssociations]) association.take((0, _messageHelper.cloneMessage)(message));
|
|
178
178
|
};
|
|
179
179
|
|
|
180
180
|
proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
@@ -188,13 +188,13 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
188
188
|
|
|
189
189
|
case 'discard':
|
|
190
190
|
{
|
|
191
|
-
this[
|
|
191
|
+
this[kCompleted] = true;
|
|
192
192
|
|
|
193
193
|
this._stop();
|
|
194
194
|
|
|
195
|
-
for (const association of this[
|
|
195
|
+
for (const association of this[kAssociations]) association.discard((0, _messageHelper.cloneMessage)(message));
|
|
196
196
|
|
|
197
|
-
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[
|
|
197
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
case 'stop':
|
|
@@ -213,7 +213,7 @@ proto._stop = function stop() {
|
|
|
213
213
|
broker.cancel(`_oncompensate-${executionId}`);
|
|
214
214
|
broker.cancel('_oncollect-messages');
|
|
215
215
|
broker.cancel('_convey-messages');
|
|
216
|
-
this[
|
|
216
|
+
this[kMessageQ].purge();
|
|
217
217
|
};
|
|
218
218
|
|
|
219
219
|
proto._debug = function debug(msg) {
|
|
@@ -9,7 +9,7 @@ var _messageHelper = require("../messageHelper");
|
|
|
9
9
|
|
|
10
10
|
var _Errors = require("../error/Errors");
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
13
13
|
|
|
14
14
|
function ConditionalEventDefinition(activity, eventDefinition) {
|
|
15
15
|
const {
|
|
@@ -35,14 +35,14 @@ function ConditionalEventDefinition(activity, eventDefinition) {
|
|
|
35
35
|
const proto = ConditionalEventDefinition.prototype;
|
|
36
36
|
Object.defineProperty(proto, 'executionId', {
|
|
37
37
|
get() {
|
|
38
|
-
const message = this[
|
|
38
|
+
const message = this[kExecuteMessage];
|
|
39
39
|
return message && message.content.executionId;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
proto.execute = function execute(executeMessage) {
|
|
45
|
-
this[
|
|
45
|
+
this[kExecuteMessage] = executeMessage;
|
|
46
46
|
return this.isWaiting ? this.executeWait(executeMessage) : this.executeCatch(executeMessage);
|
|
47
47
|
};
|
|
48
48
|
|
|
@@ -110,7 +110,7 @@ proto._onWaitApiMessage = function onWaitApiMessage(routingKey, message) {
|
|
|
110
110
|
{
|
|
111
111
|
this._stopWait();
|
|
112
112
|
|
|
113
|
-
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[
|
|
113
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
|
|
114
114
|
state: 'discard'
|
|
115
115
|
}));
|
|
116
116
|
}
|
|
@@ -123,7 +123,7 @@ proto._onWaitApiMessage = function onWaitApiMessage(routingKey, message) {
|
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
proto._evaluateWait = function evaluate(message) {
|
|
126
|
-
const executeMessage = this[
|
|
126
|
+
const executeMessage = this[kExecuteMessage];
|
|
127
127
|
const broker = this.broker,
|
|
128
128
|
executeContent = executeMessage.content;
|
|
129
129
|
|
|
@@ -161,7 +161,7 @@ proto._stopWait = function stopWait() {
|
|
|
161
161
|
proto._onAttachedCompleted = function onAttachedCompleted(routingKey, message) {
|
|
162
162
|
this._stopCatch();
|
|
163
163
|
|
|
164
|
-
const executeMessage = this[
|
|
164
|
+
const executeMessage = this[kExecuteMessage];
|
|
165
165
|
const broker = this.broker,
|
|
166
166
|
executeContent = executeMessage.content;
|
|
167
167
|
|
|
@@ -198,7 +198,7 @@ proto._onCatchApiMessage = function onCatchApiMessage(routingKey, message) {
|
|
|
198
198
|
|
|
199
199
|
this._debug('discarded');
|
|
200
200
|
|
|
201
|
-
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[
|
|
201
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
|
|
202
202
|
state: 'discard'
|
|
203
203
|
}));
|
|
204
204
|
}
|
|
@@ -216,7 +216,7 @@ proto._stopCatch = function stopCatch() {
|
|
|
216
216
|
const {
|
|
217
217
|
executionId,
|
|
218
218
|
index
|
|
219
|
-
} = this[
|
|
219
|
+
} = this[kExecuteMessage].content;
|
|
220
220
|
this.activity.attachedTo.broker.cancel(`_onend-${executionId}_${index}`);
|
|
221
221
|
this.broker.cancel(`_api-${executionId}_${index}`);
|
|
222
222
|
};
|
|
@@ -9,11 +9,11 @@ var _shared = require("../shared");
|
|
|
9
9
|
|
|
10
10
|
var _messageHelper = require("../messageHelper");
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
12
|
+
const kCompleted = Symbol.for('completed');
|
|
13
|
+
const kMessageQ = Symbol.for('messageQ');
|
|
14
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
15
|
+
const kReferenceElement = Symbol.for('referenceElement');
|
|
16
|
+
const kReferenceInfo = Symbol.for('referenceInfo');
|
|
17
17
|
|
|
18
18
|
function ErrorEventDefinition(activity, eventDefinition) {
|
|
19
19
|
const {
|
|
@@ -38,13 +38,13 @@ function ErrorEventDefinition(activity, eventDefinition) {
|
|
|
38
38
|
this.environment = environment;
|
|
39
39
|
this.broker = broker;
|
|
40
40
|
this.logger = environment.Logger(type.toLowerCase());
|
|
41
|
-
const referenceElement = this[
|
|
41
|
+
const referenceElement = this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
|
|
42
42
|
|
|
43
43
|
if (!isThrowing) {
|
|
44
|
-
this[
|
|
44
|
+
this[kCompleted] = false;
|
|
45
45
|
const referenceId = referenceElement ? referenceElement.id : 'anonymous';
|
|
46
46
|
const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(referenceId)}-q`;
|
|
47
|
-
this[
|
|
47
|
+
this[kMessageQ] = broker.assertQueue(messageQueueName, {
|
|
48
48
|
autoDelete: false,
|
|
49
49
|
durable: true
|
|
50
50
|
});
|
|
@@ -58,7 +58,7 @@ function ErrorEventDefinition(activity, eventDefinition) {
|
|
|
58
58
|
const proto = ErrorEventDefinition.prototype;
|
|
59
59
|
Object.defineProperty(proto, 'executionId', {
|
|
60
60
|
get() {
|
|
61
|
-
const message = this[
|
|
61
|
+
const message = this[kExecuteMessage];
|
|
62
62
|
return message && message.content.executionId;
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -69,8 +69,8 @@ proto.execute = function execute(executeMessage) {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
proto.executeCatch = function executeCatch(executeMessage) {
|
|
72
|
-
this[
|
|
73
|
-
this[
|
|
72
|
+
this[kExecuteMessage] = executeMessage;
|
|
73
|
+
this[kCompleted] = false;
|
|
74
74
|
const executeContent = executeMessage.content;
|
|
75
75
|
const {
|
|
76
76
|
executionId,
|
|
@@ -78,13 +78,13 @@ proto.executeCatch = function executeCatch(executeMessage) {
|
|
|
78
78
|
} = executeContent;
|
|
79
79
|
const parentExecutionId = parent && parent.executionId;
|
|
80
80
|
|
|
81
|
-
const info = this[
|
|
81
|
+
const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
|
|
82
82
|
|
|
83
|
-
this[
|
|
83
|
+
this[kMessageQ].consume(this._onThrowApiMessage.bind(this), {
|
|
84
84
|
noAck: true,
|
|
85
85
|
consumerTag: `_onthrow-${executionId}`
|
|
86
86
|
});
|
|
87
|
-
if (this[
|
|
87
|
+
if (this[kCompleted]) return;
|
|
88
88
|
|
|
89
89
|
this._debug(`expect ${info.description}`);
|
|
90
90
|
|
|
@@ -105,7 +105,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
|
|
|
105
105
|
expect: { ...info.message
|
|
106
106
|
}
|
|
107
107
|
}));
|
|
108
|
-
if (this[
|
|
108
|
+
if (this[kCompleted]) return this._stop();
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
@@ -147,29 +147,29 @@ proto.executeThrow = function executeThrow(executeMessage) {
|
|
|
147
147
|
|
|
148
148
|
proto._onErrorMessage = function onErrorMessage(routingKey, message) {
|
|
149
149
|
const error = message.content.error;
|
|
150
|
-
if (!this[
|
|
150
|
+
if (!this[kReferenceElement]) return this._catchError(routingKey, message, error);
|
|
151
151
|
if (!error) return;
|
|
152
|
-
const info = this[
|
|
152
|
+
const info = this[kReferenceInfo];
|
|
153
153
|
if ('' + error.code !== '' + info.message.code) return;
|
|
154
154
|
return this._catchError(routingKey, message, error);
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
proto._onThrowApiMessage = function onThrowApiMessage(routingKey, message) {
|
|
158
158
|
const error = message.content.message;
|
|
159
|
-
if (!this[
|
|
160
|
-
const info = this[
|
|
159
|
+
if (!this[kReferenceElement]) return this._catchError(routingKey, message, error);
|
|
160
|
+
const info = this[kReferenceInfo];
|
|
161
161
|
if (info.message.id !== (error && error.id)) return;
|
|
162
162
|
return this._catchError(routingKey, message, error);
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
proto._catchError = function catchError(routingKey, message, error) {
|
|
166
|
-
this[
|
|
166
|
+
this[kCompleted] = true;
|
|
167
167
|
|
|
168
168
|
this._stop();
|
|
169
169
|
|
|
170
|
-
this._debug(`caught ${this[
|
|
170
|
+
this._debug(`caught ${this[kReferenceInfo].description}`);
|
|
171
171
|
|
|
172
|
-
const executeContent = this[
|
|
172
|
+
const executeContent = this[kExecuteMessage].content;
|
|
173
173
|
const parent = executeContent.parent;
|
|
174
174
|
const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
175
175
|
source: {
|
|
@@ -198,11 +198,11 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
198
198
|
switch (messageType) {
|
|
199
199
|
case 'discard':
|
|
200
200
|
{
|
|
201
|
-
this[
|
|
201
|
+
this[kCompleted] = true;
|
|
202
202
|
|
|
203
203
|
this._stop();
|
|
204
204
|
|
|
205
|
-
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[
|
|
205
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
case 'stop':
|
|
@@ -220,11 +220,11 @@ proto._stop = function stop() {
|
|
|
220
220
|
broker.cancel(`_onthrow-${executionId}`);
|
|
221
221
|
broker.cancel(`_onerror-${executionId}`);
|
|
222
222
|
broker.cancel(`_api-${executionId}`);
|
|
223
|
-
this[
|
|
223
|
+
this[kMessageQ].purge();
|
|
224
224
|
};
|
|
225
225
|
|
|
226
226
|
proto._getReferenceInfo = function getReferenceInfo(message) {
|
|
227
|
-
const referenceElement = this[
|
|
227
|
+
const referenceElement = this[kReferenceElement];
|
|
228
228
|
|
|
229
229
|
if (!referenceElement) {
|
|
230
230
|
return {
|
|
@@ -13,11 +13,11 @@ var _messageHelper = require("../messageHelper");
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
16
|
+
const kCompleted = Symbol.for('completed');
|
|
17
|
+
const kMessageQ = Symbol.for('messageQ');
|
|
18
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
19
|
+
const kReferenceElement = Symbol.for('referenceElement');
|
|
20
|
+
const kReference = Symbol.for('reference');
|
|
21
21
|
|
|
22
22
|
function EscalationEventDefinition(activity, eventDefinition) {
|
|
23
23
|
const {
|
|
@@ -41,13 +41,13 @@ function EscalationEventDefinition(activity, eventDefinition) {
|
|
|
41
41
|
this.activity = activity;
|
|
42
42
|
this.broker = broker;
|
|
43
43
|
this.logger = environment.Logger(type.toLowerCase());
|
|
44
|
-
const referenceElement = this[
|
|
44
|
+
const referenceElement = this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
|
|
45
45
|
|
|
46
46
|
if (!isThrowing) {
|
|
47
|
-
this[
|
|
47
|
+
this[kCompleted] = false;
|
|
48
48
|
const referenceId = referenceElement ? referenceElement.id : 'anonymous';
|
|
49
49
|
const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(referenceId)}-q`;
|
|
50
|
-
this[
|
|
50
|
+
this[kMessageQ] = broker.assertQueue(messageQueueName, {
|
|
51
51
|
autoDelete: false,
|
|
52
52
|
durable: true
|
|
53
53
|
});
|
|
@@ -61,7 +61,7 @@ function EscalationEventDefinition(activity, eventDefinition) {
|
|
|
61
61
|
const proto = EscalationEventDefinition.prototype;
|
|
62
62
|
Object.defineProperty(proto, 'executionId', {
|
|
63
63
|
get() {
|
|
64
|
-
const message = this[
|
|
64
|
+
const message = this[kExecuteMessage];
|
|
65
65
|
return message && message.content.executionId;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -72,22 +72,22 @@ proto.execute = function execute(executeMessage) {
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
proto.executeCatch = function executeCatch(executeMessage) {
|
|
75
|
-
this[
|
|
76
|
-
this[
|
|
75
|
+
this[kExecuteMessage] = executeMessage;
|
|
76
|
+
this[kCompleted] = false;
|
|
77
77
|
const executeContent = executeMessage.content;
|
|
78
78
|
const {
|
|
79
79
|
executionId,
|
|
80
80
|
parent
|
|
81
81
|
} = executeContent;
|
|
82
82
|
|
|
83
|
-
const info = this[
|
|
83
|
+
const info = this[kReference] = this._getReferenceInfo(executeMessage);
|
|
84
84
|
|
|
85
85
|
const broker = this.broker;
|
|
86
|
-
this[
|
|
86
|
+
this[kMessageQ].consume(this._onCatchMessage.bind(this), {
|
|
87
87
|
noAck: true,
|
|
88
88
|
consumerTag: `_onescalate-${executionId}`
|
|
89
89
|
});
|
|
90
|
-
if (this[
|
|
90
|
+
if (this[kCompleted]) return;
|
|
91
91
|
broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
|
|
92
92
|
noAck: true,
|
|
93
93
|
consumerTag: `_api-${executionId}`
|
|
@@ -130,16 +130,16 @@ proto.executeThrow = function executeThrow(executeMessage) {
|
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
proto._onCatchMessage = function onCatchMessage(routingKey, message) {
|
|
133
|
-
const info = this[
|
|
133
|
+
const info = this[kReference];
|
|
134
134
|
if ((0, _getPropertyValue.default)(message, 'content.message.id') !== info.message.id) return;
|
|
135
135
|
const output = message.content.message;
|
|
136
|
-
this[
|
|
136
|
+
this[kCompleted] = true;
|
|
137
137
|
|
|
138
138
|
this._stop();
|
|
139
139
|
|
|
140
140
|
this._debug(`caught ${info.description}`);
|
|
141
141
|
|
|
142
|
-
const executeContent = this[
|
|
142
|
+
const executeContent = this[kExecuteMessage].content;
|
|
143
143
|
const {
|
|
144
144
|
parent,
|
|
145
145
|
...content
|
|
@@ -169,11 +169,11 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
169
169
|
|
|
170
170
|
case 'discard':
|
|
171
171
|
{
|
|
172
|
-
this[
|
|
172
|
+
this[kCompleted] = true;
|
|
173
173
|
|
|
174
174
|
this._stop();
|
|
175
175
|
|
|
176
|
-
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[
|
|
176
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
case 'stop':
|
|
@@ -193,7 +193,7 @@ proto._stop = function stop() {
|
|
|
193
193
|
};
|
|
194
194
|
|
|
195
195
|
proto._getReferenceInfo = function getReferenceInfo(message) {
|
|
196
|
-
const referenceElement = this[
|
|
196
|
+
const referenceElement = this[kReferenceElement];
|
|
197
197
|
|
|
198
198
|
if (!referenceElement) {
|
|
199
199
|
return {
|
|
@@ -7,9 +7,9 @@ exports.default = EventDefinitionExecution;
|
|
|
7
7
|
|
|
8
8
|
var _messageHelper = require("../messageHelper");
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
10
|
+
const kCompleted = Symbol.for('completed');
|
|
11
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
12
|
+
const kStopped = Symbol.for('stopped');
|
|
13
13
|
|
|
14
14
|
function EventDefinitionExecution(activity, eventDefinitions, completedRoutingKey = 'execute.completed') {
|
|
15
15
|
this.id = activity.id;
|
|
@@ -17,9 +17,9 @@ function EventDefinitionExecution(activity, eventDefinitions, completedRoutingKe
|
|
|
17
17
|
this.broker = activity.broker;
|
|
18
18
|
this.eventDefinitions = eventDefinitions;
|
|
19
19
|
this.completedRoutingKey = completedRoutingKey;
|
|
20
|
-
this[
|
|
21
|
-
this[
|
|
22
|
-
this[
|
|
20
|
+
this[kCompleted] = false;
|
|
21
|
+
this[kStopped] = false;
|
|
22
|
+
this[kExecuteMessage] = null;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const proto = EventDefinitionExecution.prototype;
|
|
@@ -27,7 +27,7 @@ Object.defineProperty(proto, 'completed', {
|
|
|
27
27
|
enumerable: true,
|
|
28
28
|
|
|
29
29
|
get() {
|
|
30
|
-
return this[
|
|
30
|
+
return this[kCompleted];
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
});
|
|
@@ -35,7 +35,7 @@ Object.defineProperty(proto, 'stopped', {
|
|
|
35
35
|
enumerable: true,
|
|
36
36
|
|
|
37
37
|
get() {
|
|
38
|
-
return this[
|
|
38
|
+
return this[kStopped];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
});
|
|
@@ -45,7 +45,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
45
45
|
if (content.isDefinitionScope) return this._executeDefinition(executeMessage);
|
|
46
46
|
if (!content.isRootScope) return;
|
|
47
47
|
const broker = this.broker;
|
|
48
|
-
this[
|
|
48
|
+
this[kExecuteMessage] = executeMessage;
|
|
49
49
|
const executionId = content.executionId;
|
|
50
50
|
broker.subscribeTmp('execution', 'execute.#', this._onExecuteMessage.bind(this), {
|
|
51
51
|
noAck: true,
|
|
@@ -65,8 +65,8 @@ proto.execute = function execute(executeMessage) {
|
|
|
65
65
|
const eventDefinitions = this.eventDefinitions;
|
|
66
66
|
|
|
67
67
|
for (let index = 0; index < eventDefinitions.length; ++index) {
|
|
68
|
-
if (this[
|
|
69
|
-
if (this[
|
|
68
|
+
if (this[kCompleted]) break;
|
|
69
|
+
if (this[kStopped]) break;
|
|
70
70
|
const ed = eventDefinitions[index];
|
|
71
71
|
const edExecutionId = `${executionId}_${index}`;
|
|
72
72
|
|
|
@@ -133,12 +133,12 @@ proto._complete = function complete(message) {
|
|
|
133
133
|
index,
|
|
134
134
|
parent
|
|
135
135
|
} = message.content;
|
|
136
|
-
this[
|
|
136
|
+
this[kCompleted] = true;
|
|
137
137
|
|
|
138
138
|
this._debug(executionId, `event definition ${type} completed, index ${index}`);
|
|
139
139
|
|
|
140
140
|
const completeContent = (0, _messageHelper.cloneContent)(message.content, {
|
|
141
|
-
executionId: this[
|
|
141
|
+
executionId: this[kExecuteMessage].content.executionId,
|
|
142
142
|
isRootScope: true
|
|
143
143
|
});
|
|
144
144
|
completeContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
@@ -161,7 +161,7 @@ proto._executeDefinition = function executeDefinition(message) {
|
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
proto._stop = function stop() {
|
|
164
|
-
this[
|
|
164
|
+
this[kStopped] = true;
|
|
165
165
|
this.broker.cancel('_eventdefinition-execution-execute-tag');
|
|
166
166
|
this.broker.cancel('_eventdefinition-execution-api-tag');
|
|
167
167
|
};
|
|
@@ -13,9 +13,9 @@ var _messageHelper = require("../messageHelper");
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
16
|
+
const kCompleted = Symbol.for('completed');
|
|
17
|
+
const kMessageQ = Symbol.for('messageQ');
|
|
18
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
19
19
|
|
|
20
20
|
function LinkEventDefinition(activity, eventDefinition) {
|
|
21
21
|
const {
|
|
@@ -38,11 +38,11 @@ function LinkEventDefinition(activity, eventDefinition) {
|
|
|
38
38
|
this.activity = activity;
|
|
39
39
|
this.broker = broker;
|
|
40
40
|
this.logger = environment.Logger(type.toLowerCase());
|
|
41
|
-
this[
|
|
41
|
+
this[kCompleted] = false;
|
|
42
42
|
|
|
43
43
|
if (!isThrowing) {
|
|
44
44
|
const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(reference.linkName)}-q`;
|
|
45
|
-
this[
|
|
45
|
+
this[kMessageQ] = broker.assertQueue(messageQueueName, {
|
|
46
46
|
autoDelete: false,
|
|
47
47
|
durable: true
|
|
48
48
|
});
|
|
@@ -60,7 +60,7 @@ function LinkEventDefinition(activity, eventDefinition) {
|
|
|
60
60
|
const proto = LinkEventDefinition.prototype;
|
|
61
61
|
Object.defineProperty(proto, 'executionId', {
|
|
62
62
|
get() {
|
|
63
|
-
const message = this[
|
|
63
|
+
const message = this[kExecuteMessage];
|
|
64
64
|
return message && message.content.executionId;
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -71,19 +71,19 @@ proto.execute = function execute(executeMessage) {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
proto.executeCatch = function executeCatch(executeMessage) {
|
|
74
|
-
this[
|
|
75
|
-
this[
|
|
74
|
+
this[kExecuteMessage] = executeMessage;
|
|
75
|
+
this[kCompleted] = false;
|
|
76
76
|
const executeContent = executeMessage.content;
|
|
77
77
|
const {
|
|
78
78
|
executionId,
|
|
79
79
|
parent
|
|
80
80
|
} = executeContent;
|
|
81
81
|
const parentExecutionId = parent.executionId;
|
|
82
|
-
this[
|
|
82
|
+
this[kMessageQ].consume(this._onCatchLink.bind(this), {
|
|
83
83
|
noAck: true,
|
|
84
84
|
consumerTag: `_api-link-${executionId}`
|
|
85
85
|
});
|
|
86
|
-
if (this[
|
|
86
|
+
if (this[kCompleted]) return;
|
|
87
87
|
const broker = this.broker;
|
|
88
88
|
|
|
89
89
|
const onApiMessage = this._onApiMessage.bind(this);
|
|
@@ -156,13 +156,13 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
156
156
|
};
|
|
157
157
|
|
|
158
158
|
proto._complete = function complete(verb, output) {
|
|
159
|
-
this[
|
|
159
|
+
this[kCompleted] = true;
|
|
160
160
|
|
|
161
161
|
this._stop();
|
|
162
162
|
|
|
163
163
|
this._debug(`${verb} link ${this.reference.linkName}`);
|
|
164
164
|
|
|
165
|
-
const executeContent = this[
|
|
165
|
+
const executeContent = this[kExecuteMessage].content;
|
|
166
166
|
const parent = executeContent.parent;
|
|
167
167
|
const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
168
168
|
link: { ...this.reference
|
|
@@ -183,11 +183,11 @@ proto._complete = function complete(verb, output) {
|
|
|
183
183
|
};
|
|
184
184
|
|
|
185
185
|
proto._discard = function discard() {
|
|
186
|
-
this[
|
|
186
|
+
this[kCompleted] = true;
|
|
187
187
|
|
|
188
188
|
this._stop();
|
|
189
189
|
|
|
190
|
-
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[
|
|
190
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
|
|
191
191
|
};
|
|
192
192
|
|
|
193
193
|
proto._stop = function stop() {
|
|
@@ -196,7 +196,7 @@ proto._stop = function stop() {
|
|
|
196
196
|
broker.cancel(`_api-link-${executionId}`);
|
|
197
197
|
broker.cancel(`_api-parent-${executionId}`);
|
|
198
198
|
broker.cancel(`_api-${executionId}`);
|
|
199
|
-
this[
|
|
199
|
+
this[kMessageQ].purge();
|
|
200
200
|
};
|
|
201
201
|
|
|
202
202
|
proto._onDiscard = function onDiscard(_, message) {
|