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
|
@@ -16,11 +16,11 @@ var _shared = require("../shared");
|
|
|
16
16
|
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
19
|
+
const kAttachedTags = Symbol.for('attachedConsumers');
|
|
20
|
+
const kCompleteContent = Symbol.for('completeContent');
|
|
21
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
22
|
+
const kExecution = Symbol.for('execution');
|
|
23
|
+
const kShovels = Symbol.for('shovels');
|
|
24
24
|
|
|
25
25
|
function BoundaryEvent(activityDef, context) {
|
|
26
26
|
return new _Activity.default(BoundaryEventBehaviour, activityDef, context);
|
|
@@ -33,15 +33,15 @@ function BoundaryEventBehaviour(activity) {
|
|
|
33
33
|
this.activity = activity;
|
|
34
34
|
this.environment = activity.environment;
|
|
35
35
|
this.broker = activity.broker;
|
|
36
|
-
this[
|
|
37
|
-
this[
|
|
38
|
-
this[
|
|
36
|
+
this[kExecution] = activity.eventDefinitions && new _EventDefinitionExecution.default(activity, activity.eventDefinitions, 'execute.bound.completed');
|
|
37
|
+
this[kShovels] = [];
|
|
38
|
+
this[kAttachedTags] = [];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const proto = BoundaryEventBehaviour.prototype;
|
|
42
42
|
Object.defineProperty(proto, 'executionId', {
|
|
43
43
|
get() {
|
|
44
|
-
const message = this[
|
|
44
|
+
const message = this[kExecuteMessage];
|
|
45
45
|
return message && message.content.executionId;
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -61,34 +61,35 @@ proto.execute = function execute(executeMessage) {
|
|
|
61
61
|
isRootScope,
|
|
62
62
|
executionId
|
|
63
63
|
} = executeMessage.content;
|
|
64
|
-
const eventDefinitionExecution = this[
|
|
64
|
+
const eventDefinitionExecution = this[kExecution];
|
|
65
65
|
|
|
66
66
|
if (isRootScope) {
|
|
67
|
-
this[
|
|
67
|
+
this[kExecuteMessage] = executeMessage;
|
|
68
68
|
const broker = this.broker;
|
|
69
|
-
|
|
70
|
-
if (eventDefinitionExecution && !this.environment.settings.strict) {
|
|
71
|
-
broker.subscribeTmp('execution', 'execute.expect', this._onExpectMessage.bind(this), {
|
|
72
|
-
noAck: true,
|
|
73
|
-
consumerTag: '_expect-tag'
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
69
|
const consumerTag = `_bound-listener-${executionId}`;
|
|
78
70
|
this.attachedTo.broker.subscribeTmp('event', 'activity.leave', this._onAttachedLeave.bind(this), {
|
|
79
71
|
noAck: true,
|
|
80
72
|
consumerTag,
|
|
81
73
|
priority: 300
|
|
82
74
|
});
|
|
83
|
-
this[
|
|
84
|
-
broker.subscribeOnce('execution', 'execute.detach', this._onDetachMessage.bind(this), {
|
|
85
|
-
consumerTag: '_detach-tag'
|
|
86
|
-
});
|
|
75
|
+
this[kAttachedTags].push(consumerTag);
|
|
87
76
|
broker.subscribeOnce('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
|
|
88
77
|
consumerTag: `_api-${executionId}`
|
|
89
78
|
});
|
|
90
|
-
broker.
|
|
91
|
-
|
|
79
|
+
const execQ = broker.assertQueue(`_bound-execution-${executionId}`, {
|
|
80
|
+
durable: false,
|
|
81
|
+
autoDelete: true
|
|
82
|
+
});
|
|
83
|
+
broker.bindQueue(execQ.name, 'execution', 'execute.detach');
|
|
84
|
+
broker.bindQueue(execQ.name, 'execution', 'execute.bound.completed');
|
|
85
|
+
broker.bindQueue(execQ.name, 'execution', 'execute.repeat');
|
|
86
|
+
|
|
87
|
+
if (eventDefinitionExecution && !this.environment.settings.strict) {
|
|
88
|
+
broker.bindQueue(execQ.name, 'execution', 'execute.expect');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
execQ.consume(this._onExecutionMessage.bind(this), {
|
|
92
|
+
consumerTag: '_execution-tag'
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
95
|
|
|
@@ -97,19 +98,37 @@ proto.execute = function execute(executeMessage) {
|
|
|
97
98
|
}
|
|
98
99
|
};
|
|
99
100
|
|
|
101
|
+
proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
102
|
+
message.ack();
|
|
103
|
+
|
|
104
|
+
switch (routingKey) {
|
|
105
|
+
case 'execute.detach':
|
|
106
|
+
return this._onDetachMessage(routingKey, message);
|
|
107
|
+
|
|
108
|
+
case 'execute.bound.completed':
|
|
109
|
+
return this._onCompleted(routingKey, message);
|
|
110
|
+
|
|
111
|
+
case 'execute.repeat':
|
|
112
|
+
return this._onRepeatMessage(routingKey, message);
|
|
113
|
+
|
|
114
|
+
case 'execute.expect':
|
|
115
|
+
return this._onExpectMessage(routingKey, message);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
100
119
|
proto._onCompleted = function onCompleted(_, {
|
|
101
120
|
content
|
|
102
121
|
}) {
|
|
103
122
|
if (!this.cancelActivity && !content.cancelActivity) {
|
|
104
123
|
this._stop();
|
|
105
124
|
|
|
106
|
-
return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content
|
|
125
|
+
return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content, {
|
|
126
|
+
cancelActivity: false
|
|
127
|
+
}));
|
|
107
128
|
}
|
|
108
129
|
|
|
109
|
-
this[
|
|
110
|
-
const
|
|
111
|
-
inbound
|
|
112
|
-
} = this[executeMessageSymbol].content;
|
|
130
|
+
this[kCompleteContent] = content;
|
|
131
|
+
const inbound = this[kExecuteMessage].content.inbound;
|
|
113
132
|
const attachedToContent = inbound && inbound[0];
|
|
114
133
|
const attachedTo = this.attachedTo;
|
|
115
134
|
this.activity.logger.debug(`<${this.executionId} (${this.id})> cancel ${attachedTo.status} activity <${attachedToContent.executionId} (${attachedToContent.id})>`);
|
|
@@ -125,8 +144,8 @@ proto._onAttachedLeave = function onAttachedLeave(_, {
|
|
|
125
144
|
|
|
126
145
|
this._stop();
|
|
127
146
|
|
|
128
|
-
const completeContent = this[
|
|
129
|
-
if (!completeContent) return this.broker.publish('execution', 'execute.discard', this[
|
|
147
|
+
const completeContent = this[kCompleteContent];
|
|
148
|
+
if (!completeContent) return this.broker.publish('execution', 'execute.discard', this[kExecuteMessage].content);
|
|
130
149
|
return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(completeContent));
|
|
131
150
|
};
|
|
132
151
|
|
|
@@ -139,7 +158,7 @@ proto._onExpectMessage = function onExpectMessage(_, {
|
|
|
139
158
|
} = content;
|
|
140
159
|
const attachedTo = this.attachedTo;
|
|
141
160
|
const errorConsumerTag = `_bound-error-listener-${executionId}`;
|
|
142
|
-
this[
|
|
161
|
+
this[kAttachedTags].push(errorConsumerTag);
|
|
143
162
|
attachedTo.broker.subscribeTmp('event', 'activity.error', (__, errorMessage) => {
|
|
144
163
|
if (errorMessage.content.id !== attachedTo.id) return;
|
|
145
164
|
this.broker.publish('execution', expectRoutingKey, (0, _messageHelper.cloneContent)(errorMessage.content));
|
|
@@ -167,7 +186,7 @@ proto._onDetachMessage = function onDetachMessage(_, {
|
|
|
167
186
|
sourcePattern
|
|
168
187
|
} = content;
|
|
169
188
|
const shovelName = `_detached-${(0, _shared.brokerSafeId)(id)}_${detachId}`;
|
|
170
|
-
this[
|
|
189
|
+
this[kShovels].push(shovelName);
|
|
171
190
|
const broker = this.broker;
|
|
172
191
|
attachedTo.broker.createShovel(shovelName, {
|
|
173
192
|
exchange: sourceExchange,
|
|
@@ -199,17 +218,27 @@ proto._onApiMessage = function onApiMessage(_, message) {
|
|
|
199
218
|
}
|
|
200
219
|
};
|
|
201
220
|
|
|
221
|
+
proto._onRepeatMessage = function onRepeatMessage(_, message) {
|
|
222
|
+
if (this.cancelActivity) return;
|
|
223
|
+
const executeMessage = this[kExecuteMessage];
|
|
224
|
+
const repeat = message.content.repeat;
|
|
225
|
+
this.broker.getQueue('inbound-q').queueMessage({
|
|
226
|
+
routingKey: 'activity.restart'
|
|
227
|
+
}, (0, _messageHelper.cloneContent)(executeMessage.content.inbound[0], {
|
|
228
|
+
repeat
|
|
229
|
+
}));
|
|
230
|
+
};
|
|
231
|
+
|
|
202
232
|
proto._stop = function stop(detach) {
|
|
203
233
|
const attachedTo = this.attachedTo,
|
|
204
234
|
broker = this.broker,
|
|
205
235
|
executionId = this.executionId;
|
|
206
236
|
|
|
207
|
-
for (const tag of this[
|
|
237
|
+
for (const tag of this[kAttachedTags].splice(0)) attachedTo.broker.cancel(tag);
|
|
208
238
|
|
|
209
|
-
for (const shovelName of this[
|
|
239
|
+
for (const shovelName of this[kShovels].splice(0)) attachedTo.broker.closeShovel(shovelName);
|
|
210
240
|
|
|
211
|
-
broker.cancel('
|
|
212
|
-
broker.cancel('_detach-tag');
|
|
241
|
+
broker.cancel('_execution-tag');
|
|
213
242
|
broker.cancel(`_execution-completed-${executionId}`);
|
|
214
243
|
if (detach) return;
|
|
215
244
|
broker.cancel(`_api-${executionId}`);
|
|
@@ -14,7 +14,7 @@ var _messageHelper = require("../messageHelper");
|
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const kExecution = Symbol.for('execution');
|
|
18
18
|
|
|
19
19
|
function EndEvent(activityDef, context) {
|
|
20
20
|
return new _Activity.default(EndEventBehaviour, { ...activityDef,
|
|
@@ -26,11 +26,11 @@ function EndEventBehaviour(activity) {
|
|
|
26
26
|
this.id = activity.id;
|
|
27
27
|
this.type = activity.type;
|
|
28
28
|
this.broker = activity.broker;
|
|
29
|
-
this[
|
|
29
|
+
this[kExecution] = activity.eventDefinitions && new _EventDefinitionExecution.default(activity, activity.eventDefinitions);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
EndEventBehaviour.prototype.execute = function execute(executeMessage) {
|
|
33
|
-
const execution = this[
|
|
33
|
+
const execution = this[kExecution];
|
|
34
34
|
|
|
35
35
|
if (execution) {
|
|
36
36
|
return execution.execute(executeMessage);
|
|
@@ -14,7 +14,7 @@ var _messageHelper = require("../messageHelper");
|
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const kExecution = Symbol.for('execution');
|
|
18
18
|
|
|
19
19
|
function IntermediateCatchEvent(activityDef, context) {
|
|
20
20
|
return new _Activity.default(IntermediateCatchEventBehaviour, activityDef, context);
|
|
@@ -24,11 +24,11 @@ function IntermediateCatchEventBehaviour(activity) {
|
|
|
24
24
|
this.id = activity.id;
|
|
25
25
|
this.type = activity.type;
|
|
26
26
|
this.broker = activity.broker;
|
|
27
|
-
this[
|
|
27
|
+
this[kExecution] = activity.eventDefinitions && new _EventDefinitionExecution.default(activity, activity.eventDefinitions);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
IntermediateCatchEventBehaviour.prototype.execute = function execute(executeMessage) {
|
|
31
|
-
const execution = this[
|
|
31
|
+
const execution = this[kExecution];
|
|
32
32
|
|
|
33
33
|
if (execution) {
|
|
34
34
|
return execution.execute(executeMessage);
|
|
@@ -14,7 +14,7 @@ var _messageHelper = require("../messageHelper");
|
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const kExecution = Symbol.for('execution');
|
|
18
18
|
|
|
19
19
|
function IntermediateThrowEvent(activityDef, context) {
|
|
20
20
|
return new _Activity.default(IntermediateThrowEventBehaviour, { ...activityDef,
|
|
@@ -26,11 +26,11 @@ function IntermediateThrowEventBehaviour(activity) {
|
|
|
26
26
|
this.id = activity.id;
|
|
27
27
|
this.type = activity.type;
|
|
28
28
|
this.broker = activity.broker;
|
|
29
|
-
this[
|
|
29
|
+
this[kExecution] = activity.eventDefinitions && new _EventDefinitionExecution.default(activity, activity.eventDefinitions);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
IntermediateThrowEventBehaviour.prototype.execute = function execute(executeMessage) {
|
|
33
|
-
const execution = this[
|
|
33
|
+
const execution = this[kExecution];
|
|
34
34
|
|
|
35
35
|
if (execution) {
|
|
36
36
|
return execution.execute(executeMessage);
|
|
@@ -14,8 +14,8 @@ var _messageHelper = require("../messageHelper");
|
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
const
|
|
17
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
18
|
+
const kExecution = Symbol.for('execution');
|
|
19
19
|
|
|
20
20
|
function StartEvent(activityDef, context) {
|
|
21
21
|
return new _Activity.default(StartEventBehaviour, activityDef, context);
|
|
@@ -26,20 +26,20 @@ function StartEventBehaviour(activity) {
|
|
|
26
26
|
this.type = activity.type;
|
|
27
27
|
this.activity = activity;
|
|
28
28
|
this.broker = activity.broker;
|
|
29
|
-
this[
|
|
29
|
+
this[kExecution] = activity.eventDefinitions && new _EventDefinitionExecution.default(activity, activity.eventDefinitions);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const proto = StartEventBehaviour.prototype;
|
|
33
33
|
Object.defineProperty(proto, 'executionId', {
|
|
34
34
|
get() {
|
|
35
|
-
const message = this[
|
|
35
|
+
const message = this[kExecuteMessage];
|
|
36
36
|
return message && message.content.executionId;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
proto.execute = function execute(executeMessage) {
|
|
42
|
-
const execution = this[
|
|
42
|
+
const execution = this[kExecution];
|
|
43
43
|
|
|
44
44
|
if (execution) {
|
|
45
45
|
return execution.execute(executeMessage);
|
|
@@ -53,7 +53,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const executionId = content.executionId;
|
|
56
|
-
this[
|
|
56
|
+
this[kExecuteMessage] = executeMessage;
|
|
57
57
|
broker.subscribeTmp('api', `activity.#.${executionId}`, (...args) => this._onApiMessage(...args), {
|
|
58
58
|
noAck: true,
|
|
59
59
|
consumerTag: `_api-${executionId}`,
|
|
@@ -83,7 +83,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
83
83
|
{
|
|
84
84
|
this._stop();
|
|
85
85
|
|
|
86
|
-
const content = this[
|
|
86
|
+
const content = this[kExecuteMessage].content;
|
|
87
87
|
return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content, {
|
|
88
88
|
output: message.content.message,
|
|
89
89
|
state: 'signal'
|
|
@@ -96,7 +96,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
96
96
|
{
|
|
97
97
|
this._stop();
|
|
98
98
|
|
|
99
|
-
const content = this[
|
|
99
|
+
const content = this[kExecuteMessage].content;
|
|
100
100
|
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(content), {
|
|
101
101
|
correlationId
|
|
102
102
|
});
|
|
@@ -117,7 +117,7 @@ proto._onDelegatedApiMessage = function onDelegatedApiMessage(routingKey, messag
|
|
|
117
117
|
type,
|
|
118
118
|
correlationId
|
|
119
119
|
} = message.properties;
|
|
120
|
-
const executeContent = this[
|
|
120
|
+
const executeContent = this[kExecuteMessage].content;
|
|
121
121
|
this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
122
122
|
message: { ...content.message
|
|
123
123
|
}
|
|
@@ -13,7 +13,7 @@ var _Api = require("../Api");
|
|
|
13
13
|
|
|
14
14
|
var _shared = require("../shared");
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const kCounters = Symbol.for('counters');
|
|
17
17
|
|
|
18
18
|
function Association(associationDef, {
|
|
19
19
|
environment
|
|
@@ -37,7 +37,7 @@ function Association(associationDef, {
|
|
|
37
37
|
this.isAssociation = true;
|
|
38
38
|
this.environment = environment;
|
|
39
39
|
const logger = this.logger = environment.Logger(type.toLowerCase());
|
|
40
|
-
this[
|
|
40
|
+
this[kCounters] = {
|
|
41
41
|
complete: 0,
|
|
42
42
|
take: 0,
|
|
43
43
|
discard: 0
|
|
@@ -64,7 +64,7 @@ Object.defineProperty(proto, 'counters', {
|
|
|
64
64
|
enumerable: true,
|
|
65
65
|
|
|
66
66
|
get() {
|
|
67
|
-
return { ...this[
|
|
67
|
+
return { ...this[kCounters]
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -72,7 +72,7 @@ Object.defineProperty(proto, 'counters', {
|
|
|
72
72
|
|
|
73
73
|
proto.take = function take(content = {}) {
|
|
74
74
|
this.logger.debug(`<${this.id}> take target <${this.targetId}>`);
|
|
75
|
-
++this[
|
|
75
|
+
++this[kCounters].take;
|
|
76
76
|
|
|
77
77
|
this._publishEvent('take', content);
|
|
78
78
|
|
|
@@ -81,7 +81,7 @@ proto.take = function take(content = {}) {
|
|
|
81
81
|
|
|
82
82
|
proto.discard = function discard(content = {}) {
|
|
83
83
|
this.logger.debug(`<${this.id}> discard target <${this.targetId}>`);
|
|
84
|
-
++this[
|
|
84
|
+
++this[kCounters].discard;
|
|
85
85
|
|
|
86
86
|
this._publishEvent('discard', content);
|
|
87
87
|
|
|
@@ -90,7 +90,7 @@ proto.discard = function discard(content = {}) {
|
|
|
90
90
|
|
|
91
91
|
proto.complete = function complete(content = {}) {
|
|
92
92
|
this.logger.debug(`<${this.id}> completed target <${this.targetId}>`);
|
|
93
|
-
++this[
|
|
93
|
+
++this[kCounters].complete;
|
|
94
94
|
|
|
95
95
|
this._publishEvent('complete', content);
|
|
96
96
|
|
|
@@ -105,7 +105,7 @@ proto.getState = function getState() {
|
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
proto.recover = function recover(state) {
|
|
108
|
-
Object.assign(this[
|
|
108
|
+
Object.assign(this[kCounters], state.counters);
|
|
109
109
|
this.broker.recover(state.broker);
|
|
110
110
|
};
|
|
111
111
|
|
|
@@ -11,8 +11,8 @@ var _messageHelper = require("../messageHelper");
|
|
|
11
11
|
|
|
12
12
|
var _EventBroker = require("../EventBroker");
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const kCounters = Symbol.for('counters');
|
|
15
|
+
const kSourceElement = Symbol.for('sourceElement');
|
|
16
16
|
|
|
17
17
|
function MessageFlow(flowDef, context) {
|
|
18
18
|
const {
|
|
@@ -33,7 +33,7 @@ function MessageFlow(flowDef, context) {
|
|
|
33
33
|
this.behaviour = behaviour;
|
|
34
34
|
this.environment = context.environment;
|
|
35
35
|
this.context = context;
|
|
36
|
-
this[
|
|
36
|
+
this[kCounters] = {
|
|
37
37
|
messages: 0
|
|
38
38
|
};
|
|
39
39
|
const {
|
|
@@ -48,7 +48,7 @@ function MessageFlow(flowDef, context) {
|
|
|
48
48
|
this.once = once;
|
|
49
49
|
this.emit = emit;
|
|
50
50
|
this.waitFor = waitFor;
|
|
51
|
-
this[
|
|
51
|
+
this[kSourceElement] = context.getActivityById(source.id) || context.getProcessById(source.processId);
|
|
52
52
|
this.logger = context.environment.Logger(type.toLowerCase());
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -57,7 +57,7 @@ Object.defineProperty(proto, 'counters', {
|
|
|
57
57
|
enumerable: true,
|
|
58
58
|
|
|
59
59
|
get() {
|
|
60
|
-
return { ...this[
|
|
60
|
+
return { ...this[kCounters]
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -72,7 +72,7 @@ proto.getState = function getState() {
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
proto.recover = function recover(state) {
|
|
75
|
-
Object.assign(this[
|
|
75
|
+
Object.assign(this[kCounters], state.counters);
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
proto.getApi = function getApi() {
|
|
@@ -80,7 +80,7 @@ proto.getApi = function getApi() {
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
proto.activate = function activate() {
|
|
83
|
-
const sourceElement = this[
|
|
83
|
+
const sourceElement = this[kSourceElement];
|
|
84
84
|
const safeId = (0, _shared.brokerSafeId)(this.id);
|
|
85
85
|
sourceElement.on('message', this.deactivate.bind(this), {
|
|
86
86
|
consumerTag: `_message-on-message-${safeId}`
|
|
@@ -91,7 +91,7 @@ proto.activate = function activate() {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
proto.deactivate = function deactivate() {
|
|
94
|
-
const sourceElement = this[
|
|
94
|
+
const sourceElement = this[kSourceElement];
|
|
95
95
|
const safeId = (0, _shared.brokerSafeId)(this.id);
|
|
96
96
|
sourceElement.broker.cancel(`_message-on-end-${safeId}`);
|
|
97
97
|
sourceElement.broker.cancel(`_message-on-message-${safeId}`);
|
|
@@ -100,7 +100,7 @@ proto.deactivate = function deactivate() {
|
|
|
100
100
|
proto._onSourceEnd = function onSourceEnd({
|
|
101
101
|
content
|
|
102
102
|
}) {
|
|
103
|
-
++this[
|
|
103
|
+
++this[kCounters].messages;
|
|
104
104
|
const source = this.source;
|
|
105
105
|
const target = this.target;
|
|
106
106
|
this.logger.debug(`<${this.id}> sending message from <${source.processId}.${source.id}> to <${target.id ? `${target.processId}.${target.id}` : target.processId}>`);
|
|
@@ -17,7 +17,7 @@ var _Api = require("../Api");
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const kCounters = Symbol.for('counters');
|
|
21
21
|
var _default = SequenceFlow;
|
|
22
22
|
exports.default = _default;
|
|
23
23
|
|
|
@@ -45,7 +45,7 @@ function SequenceFlow(flowDef, {
|
|
|
45
45
|
this.isSequenceFlow = true;
|
|
46
46
|
this.environment = environment;
|
|
47
47
|
const logger = this.logger = environment.Logger(type.toLowerCase());
|
|
48
|
-
this[
|
|
48
|
+
this[kCounters] = {
|
|
49
49
|
looped: 0,
|
|
50
50
|
take: 0,
|
|
51
51
|
discard: 0
|
|
@@ -75,7 +75,7 @@ Object.defineProperty(proto, 'counters', {
|
|
|
75
75
|
enumerable: true,
|
|
76
76
|
|
|
77
77
|
get() {
|
|
78
|
-
return { ...this[
|
|
78
|
+
return { ...this[kCounters]
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -87,7 +87,7 @@ proto.take = function take(content = {}) {
|
|
|
87
87
|
sequenceId
|
|
88
88
|
} = content;
|
|
89
89
|
this.logger.debug(`<${sequenceId} (${this.id})> take, target <${this.targetId}>`);
|
|
90
|
-
++this[
|
|
90
|
+
++this[kCounters].take;
|
|
91
91
|
|
|
92
92
|
this._publishEvent('take', content);
|
|
93
93
|
|
|
@@ -101,14 +101,14 @@ proto.discard = function discard(content = {}) {
|
|
|
101
101
|
const discardSequence = content.discardSequence = (content.discardSequence || []).slice();
|
|
102
102
|
|
|
103
103
|
if (discardSequence.indexOf(this.targetId) > -1) {
|
|
104
|
-
++this[
|
|
104
|
+
++this[kCounters].looped;
|
|
105
105
|
this.logger.debug(`<${this.id}> discard loop detected <${this.sourceId}> -> <${this.targetId}>. Stop.`);
|
|
106
106
|
return this._publishEvent('looped', content);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
discardSequence.push(this.sourceId);
|
|
110
110
|
this.logger.debug(`<${sequenceId} (${this.id})> discard, target <${this.targetId}>`);
|
|
111
|
-
++this[
|
|
111
|
+
++this[kCounters].discard;
|
|
112
112
|
|
|
113
113
|
this._publishEvent('discard', content);
|
|
114
114
|
};
|
|
@@ -121,7 +121,7 @@ proto.getState = function getState() {
|
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
proto.recover = function recover(state) {
|
|
124
|
-
Object.assign(this[
|
|
124
|
+
Object.assign(this[kCounters], state.counters);
|
|
125
125
|
this.broker.recover(state.broker);
|
|
126
126
|
};
|
|
127
127
|
|
|
@@ -12,8 +12,8 @@ var _messageHelper = require("../messageHelper");
|
|
|
12
12
|
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const kCompleted = Symbol.for('completed');
|
|
16
|
+
const kTargets = Symbol.for('targets');
|
|
17
17
|
|
|
18
18
|
function EventBasedGateway(activityDef, context) {
|
|
19
19
|
return new _Activity.default(EventBasedGatewayBehaviour, activityDef, context);
|
|
@@ -25,7 +25,7 @@ function EventBasedGatewayBehaviour(activity, context) {
|
|
|
25
25
|
this.activity = activity;
|
|
26
26
|
this.broker = activity.broker;
|
|
27
27
|
this.context = context;
|
|
28
|
-
this[
|
|
28
|
+
this[kTargets] = activity.outbound.map(flow => context.getActivityById(flow.targetId));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage) {
|
|
@@ -35,8 +35,8 @@ EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage)
|
|
|
35
35
|
outbound = [],
|
|
36
36
|
outboundTaken
|
|
37
37
|
} = executeContent;
|
|
38
|
-
const targets = this[
|
|
39
|
-
this[
|
|
38
|
+
const targets = this[kTargets];
|
|
39
|
+
this[kCompleted] = false;
|
|
40
40
|
if (!targets.length) return this._complete(executeContent);
|
|
41
41
|
|
|
42
42
|
for (const flow of this.activity.outbound) {
|
|
@@ -46,12 +46,12 @@ EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage)
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
if (!this[
|
|
49
|
+
if (!this[kCompleted] && outboundTaken) return;
|
|
50
50
|
const targetConsumerTag = `_gateway-listener-${this.id}`;
|
|
51
51
|
|
|
52
52
|
const onTargetCompleted = this._onTargetCompleted.bind(this, executeMessage);
|
|
53
53
|
|
|
54
|
-
for (const target of this[
|
|
54
|
+
for (const target of this[kTargets]) {
|
|
55
55
|
target.broker.subscribeOnce('event', 'activity.end', onTargetCompleted, {
|
|
56
56
|
consumerTag: targetConsumerTag
|
|
57
57
|
});
|
|
@@ -62,7 +62,7 @@ EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage)
|
|
|
62
62
|
noAck: true,
|
|
63
63
|
consumerTag: '_api-stop-execution'
|
|
64
64
|
});
|
|
65
|
-
this[
|
|
65
|
+
this[kCompleted] = false;
|
|
66
66
|
if (!executeMessage.fields.redelivered) return broker.publish('execution', 'execute.outbound.take', (0, _messageHelper.cloneContent)(executeContent, {
|
|
67
67
|
outboundTaken: true
|
|
68
68
|
}));
|
|
@@ -79,7 +79,7 @@ EventBasedGatewayBehaviour.prototype._onTargetCompleted = function onTargetCompl
|
|
|
79
79
|
|
|
80
80
|
this._stop();
|
|
81
81
|
|
|
82
|
-
for (const target of this[
|
|
82
|
+
for (const target of this[kTargets]) {
|
|
83
83
|
if (target === owner) continue;
|
|
84
84
|
target.discard();
|
|
85
85
|
}
|
|
@@ -96,14 +96,14 @@ EventBasedGatewayBehaviour.prototype._onTargetCompleted = function onTargetCompl
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
EventBasedGatewayBehaviour.prototype._complete = function complete(completedContent) {
|
|
99
|
-
this[
|
|
99
|
+
this[kCompleted] = true;
|
|
100
100
|
this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(completedContent));
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
EventBasedGatewayBehaviour.prototype._stop = function stop() {
|
|
104
104
|
const targetConsumerTag = `_gateway-listener-${this.id}`;
|
|
105
105
|
|
|
106
|
-
for (const target of this[
|
|
106
|
+
for (const target of this[kTargets]) target.broker.cancel(targetConsumerTag);
|
|
107
107
|
|
|
108
108
|
this.broker.cancel('_api-stop-execution');
|
|
109
109
|
};
|
|
@@ -11,7 +11,7 @@ var _shared = require("../shared");
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const kConsuming = Symbol.for('consuming');
|
|
15
15
|
|
|
16
16
|
function IoSpecification(activity, ioSpecificationDef, context) {
|
|
17
17
|
const {
|
|
@@ -30,14 +30,14 @@ function IoSpecification(activity, ioSpecificationDef, context) {
|
|
|
30
30
|
const proto = IoSpecification.prototype;
|
|
31
31
|
|
|
32
32
|
proto.activate = function activate() {
|
|
33
|
-
if (this[
|
|
34
|
-
this[
|
|
33
|
+
if (this[kConsuming]) return;
|
|
34
|
+
this[kConsuming] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
|
|
35
35
|
noAck: true
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
proto.deactivate = function deactivate() {
|
|
40
|
-
if (this[
|
|
40
|
+
if (this[kConsuming]) this[kConsuming] = this[kConsuming].cancel();
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
proto._onActivityEvent = function onActivityEvent(routingKey, message) {
|