bpmn-elements 6.0.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +322 -0
- package/README.md +3 -0
- package/dist/index.js +52 -44
- package/dist/src/Api.js +77 -76
- package/dist/src/Context.js +169 -175
- package/dist/src/Environment.js +90 -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 +1106 -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 +722 -409
- 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 +433 -359
- package/dist/src/process/ProcessExecution.js +744 -645
- 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 +195 -175
- package/dist/src/tasks/Task.js +17 -19
- package/index.js +2 -0
- package/package.json +13 -13
- package/src/Api.js +65 -59
- package/src/Context.js +138 -141
- package/src/Environment.js +88 -100
- package/src/EventBroker.js +67 -68
- package/src/ExtensionsMapper.js +2 -2
- package/src/MessageFormatter.js +132 -74
- package/src/activity/Activity.js +915 -775
- package/src/activity/ActivityExecution.js +293 -247
- package/src/activity/Dummy.js +2 -2
- package/src/definition/Definition.js +436 -401
- package/src/definition/DefinitionExecution.js +603 -343
- package/src/error/Errors.js +11 -6
- package/src/eventDefinitions/CancelEventDefinition.js +164 -121
- package/src/eventDefinitions/CompensateEventDefinition.js +158 -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 +16 -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 +374 -333
- package/src/process/ProcessExecution.js +606 -554
- 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
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = StartEvent;
|
|
7
6
|
exports.StartEventBehaviour = StartEventBehaviour;
|
|
7
|
+
exports.default = StartEvent;
|
|
8
8
|
|
|
9
9
|
var _Activity = _interopRequireDefault(require("../activity/Activity"));
|
|
10
10
|
|
|
@@ -14,108 +14,123 @@ var _messageHelper = require("../messageHelper");
|
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
|
|
17
|
+
const executeMessageSymbol = Symbol.for('executeMessage');
|
|
18
|
+
const executionSymbol = Symbol.for('execution');
|
|
19
|
+
|
|
17
20
|
function StartEvent(activityDef, context) {
|
|
18
|
-
return
|
|
21
|
+
return new _Activity.default(StartEventBehaviour, activityDef, context);
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
function StartEventBehaviour(activity) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const eventDefinitionExecution = eventDefinitions && (0, _EventDefinitionExecution.default)(activity, eventDefinitions);
|
|
29
|
-
const event = {
|
|
30
|
-
id,
|
|
31
|
-
type,
|
|
32
|
-
execute
|
|
33
|
-
};
|
|
34
|
-
return event;
|
|
25
|
+
this.id = activity.id;
|
|
26
|
+
this.type = activity.type;
|
|
27
|
+
this.activity = activity;
|
|
28
|
+
this.broker = activity.broker;
|
|
29
|
+
this[executionSymbol] = activity.eventDefinitions && new _EventDefinitionExecution.default(activity, activity.eventDefinitions);
|
|
30
|
+
}
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
const proto = StartEventBehaviour.prototype;
|
|
33
|
+
Object.defineProperty(proto, 'executionId', {
|
|
34
|
+
get() {
|
|
35
|
+
const message = this[executeMessageSymbol];
|
|
36
|
+
return message && message.content.executionId;
|
|
37
|
+
}
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
});
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
41
|
+
proto.execute = function execute(executeMessage) {
|
|
42
|
+
const execution = this[executionSymbol];
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
priority: 300
|
|
54
|
-
});
|
|
55
|
-
broker.subscribeTmp('api', '#.signal.*', onDelegatedApiMessage, {
|
|
56
|
-
noAck: true,
|
|
57
|
-
consumerTag: `_api-delegated-${executionId}`
|
|
58
|
-
});
|
|
59
|
-
broker.publish('event', 'activity.wait', { ...content,
|
|
60
|
-
executionId,
|
|
61
|
-
state: 'wait'
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
function onDelegatedApiMessage(routingKey, message) {
|
|
65
|
-
if (!message.properties.delegate) return;
|
|
66
|
-
const {
|
|
67
|
-
content: delegateContent
|
|
68
|
-
} = message;
|
|
69
|
-
if (!delegateContent || !delegateContent.message) return;
|
|
70
|
-
const {
|
|
71
|
-
id: signalId,
|
|
72
|
-
executionId: signalExecutionId
|
|
73
|
-
} = delegateContent.message;
|
|
74
|
-
if (signalId !== id && signalExecutionId !== executionId) return;
|
|
75
|
-
const {
|
|
76
|
-
type: messageType,
|
|
77
|
-
correlationId
|
|
78
|
-
} = message.properties;
|
|
79
|
-
broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(content, {
|
|
80
|
-
message: { ...delegateContent.message
|
|
81
|
-
}
|
|
82
|
-
}), {
|
|
83
|
-
correlationId,
|
|
84
|
-
type: messageType
|
|
85
|
-
});
|
|
86
|
-
return onApiMessage(routingKey, message);
|
|
87
|
-
}
|
|
44
|
+
if (execution) {
|
|
45
|
+
return execution.execute(executeMessage);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const content = (0, _messageHelper.cloneContent)(executeMessage.content);
|
|
49
|
+
const broker = this.broker;
|
|
88
50
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
51
|
+
if (!content.form) {
|
|
52
|
+
return broker.publish('execution', 'execute.completed', content);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const executionId = content.executionId;
|
|
56
|
+
this[executeMessageSymbol] = executeMessage;
|
|
57
|
+
broker.subscribeTmp('api', `activity.#.${executionId}`, (...args) => this._onApiMessage(...args), {
|
|
58
|
+
noAck: true,
|
|
59
|
+
consumerTag: `_api-${executionId}`,
|
|
60
|
+
priority: 300
|
|
61
|
+
});
|
|
62
|
+
broker.subscribeTmp('api', '#.signal.*', (...args) => this._onDelegatedApiMessage(...args), {
|
|
63
|
+
noAck: true,
|
|
64
|
+
consumerTag: `_api-delegated-${executionId}`
|
|
65
|
+
});
|
|
66
|
+
broker.publish('event', 'activity.wait', { ...content,
|
|
67
|
+
executionId,
|
|
68
|
+
state: 'wait'
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
73
|
+
const {
|
|
74
|
+
type: messageType,
|
|
75
|
+
correlationId
|
|
76
|
+
} = message.properties;
|
|
77
|
+
|
|
78
|
+
switch (messageType) {
|
|
79
|
+
case 'stop':
|
|
80
|
+
return this._stop();
|
|
81
|
+
|
|
82
|
+
case 'signal':
|
|
83
|
+
{
|
|
84
|
+
this._stop();
|
|
85
|
+
|
|
86
|
+
const content = this[executeMessageSymbol].content;
|
|
87
|
+
return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content, {
|
|
88
|
+
output: message.content.message,
|
|
89
|
+
state: 'signal'
|
|
90
|
+
}), {
|
|
91
|
+
correlationId
|
|
92
|
+
});
|
|
113
93
|
}
|
|
114
|
-
}
|
|
115
94
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
95
|
+
case 'discard':
|
|
96
|
+
{
|
|
97
|
+
this._stop();
|
|
98
|
+
|
|
99
|
+
const content = this[executeMessageSymbol].content;
|
|
100
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(content), {
|
|
101
|
+
correlationId
|
|
102
|
+
});
|
|
103
|
+
}
|
|
120
104
|
}
|
|
121
|
-
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
proto._onDelegatedApiMessage = function onDelegatedApiMessage(routingKey, message) {
|
|
108
|
+
if (!message.properties.delegate) return;
|
|
109
|
+
const content = message.content;
|
|
110
|
+
if (!content.message) return;
|
|
111
|
+
const {
|
|
112
|
+
id: signalId,
|
|
113
|
+
executionId: signalExecutionId
|
|
114
|
+
} = content.message;
|
|
115
|
+
if (signalId !== this.id && signalExecutionId !== this.executionId) return;
|
|
116
|
+
const {
|
|
117
|
+
type,
|
|
118
|
+
correlationId
|
|
119
|
+
} = message.properties;
|
|
120
|
+
const executeContent = this[executeMessageSymbol].content;
|
|
121
|
+
this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
122
|
+
message: { ...content.message
|
|
123
|
+
}
|
|
124
|
+
}), {
|
|
125
|
+
correlationId,
|
|
126
|
+
type
|
|
127
|
+
});
|
|
128
|
+
return this._onApiMessage(routingKey, message);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
proto._stop = function stop() {
|
|
132
|
+
const broker = this.broker,
|
|
133
|
+
executionId = this.executionId;
|
|
134
|
+
broker.cancel(`_api-${executionId}`);
|
|
135
|
+
broker.cancel(`_api-delegated-${executionId}`);
|
|
136
|
+
};
|
|
@@ -13,6 +13,8 @@ var _Api = require("../Api");
|
|
|
13
13
|
|
|
14
14
|
var _shared = require("../shared");
|
|
15
15
|
|
|
16
|
+
const countersSymbol = Symbol.for('counters');
|
|
17
|
+
|
|
16
18
|
function Association(associationDef, {
|
|
17
19
|
environment
|
|
18
20
|
}) {
|
|
@@ -20,131 +22,123 @@ function Association(associationDef, {
|
|
|
20
22
|
id,
|
|
21
23
|
type = 'association',
|
|
22
24
|
name,
|
|
23
|
-
parent
|
|
25
|
+
parent,
|
|
24
26
|
targetId,
|
|
25
27
|
sourceId,
|
|
26
28
|
behaviour = {}
|
|
27
29
|
} = associationDef;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
this.id = id;
|
|
31
|
+
this.type = type;
|
|
32
|
+
this.name = name;
|
|
33
|
+
this.parent = (0, _messageHelper.cloneParent)(parent);
|
|
34
|
+
this.behaviour = behaviour;
|
|
35
|
+
this.sourceId = sourceId;
|
|
36
|
+
this.targetId = targetId;
|
|
37
|
+
this.isAssociation = true;
|
|
38
|
+
this.environment = environment;
|
|
39
|
+
const logger = this.logger = environment.Logger(type.toLowerCase());
|
|
40
|
+
this[countersSymbol] = {
|
|
31
41
|
complete: 0,
|
|
32
42
|
take: 0,
|
|
33
43
|
discard: 0
|
|
34
44
|
};
|
|
35
|
-
const associationApi = {
|
|
36
|
-
id,
|
|
37
|
-
type,
|
|
38
|
-
name,
|
|
39
|
-
parent,
|
|
40
|
-
behaviour,
|
|
41
|
-
sourceId,
|
|
42
|
-
targetId,
|
|
43
|
-
isAssociation: true,
|
|
44
|
-
environment,
|
|
45
|
-
|
|
46
|
-
get counters() {
|
|
47
|
-
return { ...counters
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
complete,
|
|
52
|
-
discard,
|
|
53
|
-
getApi,
|
|
54
|
-
getState,
|
|
55
|
-
recover,
|
|
56
|
-
stop,
|
|
57
|
-
take
|
|
58
|
-
};
|
|
59
45
|
const {
|
|
60
46
|
broker,
|
|
61
47
|
on,
|
|
62
48
|
once,
|
|
63
49
|
waitFor
|
|
64
|
-
} =
|
|
50
|
+
} = new _EventBroker.EventBroker(this, {
|
|
65
51
|
prefix: 'association',
|
|
66
52
|
durable: true,
|
|
67
53
|
autoDelete: false
|
|
68
54
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
enumerable: true,
|
|
74
|
-
get: () => broker
|
|
75
|
-
});
|
|
55
|
+
this.broker = broker;
|
|
56
|
+
this.on = on;
|
|
57
|
+
this.once = once;
|
|
58
|
+
this.waitFor = waitFor;
|
|
76
59
|
logger.debug(`<${id}> init, <${sourceId}> -> <${targetId}>`);
|
|
77
|
-
|
|
60
|
+
}
|
|
78
61
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
publishEvent('take', content);
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
62
|
+
const proto = Association.prototype;
|
|
63
|
+
Object.defineProperty(proto, 'counters', {
|
|
64
|
+
enumerable: true,
|
|
85
65
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
publishEvent('discard', content);
|
|
90
|
-
return true;
|
|
66
|
+
get() {
|
|
67
|
+
return { ...this[countersSymbol]
|
|
68
|
+
};
|
|
91
69
|
}
|
|
92
70
|
|
|
93
|
-
|
|
94
|
-
logger.debug(`<${id}> completed target <${targetId}>`);
|
|
95
|
-
++counters.complete;
|
|
96
|
-
publishEvent('complete', content);
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
71
|
+
});
|
|
99
72
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
message: content,
|
|
104
|
-
sequenceId: (0, _shared.getUniqueId)(id)
|
|
105
|
-
});
|
|
106
|
-
broker.publish('event', `association.${action}`, eventContent, {
|
|
107
|
-
type: action
|
|
108
|
-
});
|
|
109
|
-
}
|
|
73
|
+
proto.take = function take(content = {}) {
|
|
74
|
+
this.logger.debug(`<${this.id}> take target <${this.targetId}>`);
|
|
75
|
+
++this[countersSymbol].take;
|
|
110
76
|
|
|
111
|
-
|
|
112
|
-
return { ...override,
|
|
113
|
-
id,
|
|
114
|
-
type,
|
|
115
|
-
name,
|
|
116
|
-
sourceId,
|
|
117
|
-
targetId,
|
|
118
|
-
isAssociation: true,
|
|
119
|
-
parent: (0, _messageHelper.cloneParent)(parent)
|
|
120
|
-
};
|
|
121
|
-
}
|
|
77
|
+
this._publishEvent('take', content);
|
|
122
78
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
id,
|
|
126
|
-
type,
|
|
127
|
-
name,
|
|
128
|
-
sourceId,
|
|
129
|
-
targetId,
|
|
130
|
-
counters: { ...counters
|
|
131
|
-
},
|
|
132
|
-
broker: broker.getState(true)
|
|
133
|
-
};
|
|
134
|
-
}
|
|
79
|
+
return true;
|
|
80
|
+
};
|
|
135
81
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
82
|
+
proto.discard = function discard(content = {}) {
|
|
83
|
+
this.logger.debug(`<${this.id}> discard target <${this.targetId}>`);
|
|
84
|
+
++this[countersSymbol].discard;
|
|
140
85
|
|
|
141
|
-
|
|
142
|
-
return (0, _Api.FlowApi)(broker, message || {
|
|
143
|
-
content: createMessageContent()
|
|
144
|
-
});
|
|
145
|
-
}
|
|
86
|
+
this._publishEvent('discard', content);
|
|
146
87
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
88
|
+
return true;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
proto.complete = function complete(content = {}) {
|
|
92
|
+
this.logger.debug(`<${this.id}> completed target <${this.targetId}>`);
|
|
93
|
+
++this[countersSymbol].complete;
|
|
94
|
+
|
|
95
|
+
this._publishEvent('complete', content);
|
|
96
|
+
|
|
97
|
+
return true;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
proto.getState = function getState() {
|
|
101
|
+
return this._createMessageContent({
|
|
102
|
+
counters: this.counters,
|
|
103
|
+
broker: this.broker.getState(true)
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
proto.recover = function recover(state) {
|
|
108
|
+
Object.assign(this[countersSymbol], state.counters);
|
|
109
|
+
this.broker.recover(state.broker);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
proto.getApi = function getApi(message) {
|
|
113
|
+
return (0, _Api.FlowApi)(this.broker, message || {
|
|
114
|
+
content: this._createMessageContent()
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
proto.stop = function stop() {
|
|
119
|
+
this.broker.stop();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
proto._publishEvent = function publishEvent(action, content) {
|
|
123
|
+
const eventContent = this._createMessageContent({
|
|
124
|
+
action,
|
|
125
|
+
message: content,
|
|
126
|
+
sequenceId: (0, _shared.getUniqueId)(this.id)
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
this.broker.publish('event', `association.${action}`, eventContent, {
|
|
130
|
+
type: action
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
proto._createMessageContent = function createMessageContent(override) {
|
|
135
|
+
return { ...override,
|
|
136
|
+
id: this.id,
|
|
137
|
+
type: this.type,
|
|
138
|
+
name: this.name,
|
|
139
|
+
sourceId: this.sourceId,
|
|
140
|
+
targetId: this.targetId,
|
|
141
|
+
isAssociation: true,
|
|
142
|
+
parent: (0, _messageHelper.cloneParent)(this.parent)
|
|
143
|
+
};
|
|
144
|
+
};
|
|
@@ -11,47 +11,30 @@ var _messageHelper = require("../messageHelper");
|
|
|
11
11
|
|
|
12
12
|
var _EventBroker = require("../EventBroker");
|
|
13
13
|
|
|
14
|
+
const countersSymbol = Symbol.for('counters');
|
|
15
|
+
const sourceElementSymbol = Symbol.for('sourceElement');
|
|
16
|
+
|
|
14
17
|
function MessageFlow(flowDef, context) {
|
|
15
18
|
const {
|
|
16
19
|
id,
|
|
17
|
-
type = '
|
|
20
|
+
type = 'messageflow',
|
|
18
21
|
name,
|
|
19
22
|
target,
|
|
20
23
|
source,
|
|
21
24
|
behaviour,
|
|
22
25
|
parent
|
|
23
26
|
} = flowDef;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const flowApi = {
|
|
36
|
-
id,
|
|
37
|
-
type,
|
|
38
|
-
name,
|
|
39
|
-
target,
|
|
40
|
-
source,
|
|
41
|
-
behaviour,
|
|
42
|
-
|
|
43
|
-
get counters() {
|
|
44
|
-
return { ...counters
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
activate,
|
|
49
|
-
deactivate,
|
|
50
|
-
getApi,
|
|
51
|
-
getState,
|
|
52
|
-
recover,
|
|
53
|
-
resume,
|
|
54
|
-
stop
|
|
27
|
+
this.id = id;
|
|
28
|
+
this.type = type;
|
|
29
|
+
this.name = name;
|
|
30
|
+
this.parent = (0, _messageHelper.cloneParent)(parent);
|
|
31
|
+
this.source = source;
|
|
32
|
+
this.target = target;
|
|
33
|
+
this.behaviour = behaviour;
|
|
34
|
+
this.environment = context.environment;
|
|
35
|
+
this.context = context;
|
|
36
|
+
this[countersSymbol] = {
|
|
37
|
+
messages: 0
|
|
55
38
|
};
|
|
56
39
|
const {
|
|
57
40
|
broker,
|
|
@@ -59,81 +42,81 @@ function MessageFlow(flowDef, context) {
|
|
|
59
42
|
once,
|
|
60
43
|
emit,
|
|
61
44
|
waitFor
|
|
62
|
-
} = (0, _EventBroker.MessageFlowBroker)(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
broker.publish('event', 'message.outbound', createMessage(content.message));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function onSourceMessage() {
|
|
82
|
-
deactivate();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function createMessage(message) {
|
|
86
|
-
return {
|
|
87
|
-
id,
|
|
88
|
-
type,
|
|
89
|
-
name,
|
|
90
|
-
source: { ...source
|
|
91
|
-
},
|
|
92
|
-
target: { ...target
|
|
93
|
-
},
|
|
94
|
-
parent: parent && (0, _messageHelper.cloneParent)(parent),
|
|
95
|
-
message
|
|
45
|
+
} = (0, _EventBroker.MessageFlowBroker)(this);
|
|
46
|
+
this.broker = broker;
|
|
47
|
+
this.on = on;
|
|
48
|
+
this.once = once;
|
|
49
|
+
this.emit = emit;
|
|
50
|
+
this.waitFor = waitFor;
|
|
51
|
+
this[sourceElementSymbol] = context.getActivityById(source.id) || context.getProcessById(source.processId);
|
|
52
|
+
this.logger = context.environment.Logger(type.toLowerCase());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const proto = MessageFlow.prototype;
|
|
56
|
+
Object.defineProperty(proto, 'counters', {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
|
|
59
|
+
get() {
|
|
60
|
+
return { ...this[countersSymbol]
|
|
96
61
|
};
|
|
97
62
|
}
|
|
98
63
|
|
|
99
|
-
|
|
100
|
-
deactivate();
|
|
101
|
-
broker.stop();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function getState() {
|
|
105
|
-
return {
|
|
106
|
-
id,
|
|
107
|
-
type,
|
|
108
|
-
counters: { ...counters
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function recover(state) {
|
|
114
|
-
Object.assign(counters, state.counters);
|
|
115
|
-
broker.recover(state.broker);
|
|
116
|
-
}
|
|
64
|
+
});
|
|
117
65
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
66
|
+
proto.getState = function getState() {
|
|
67
|
+
return {
|
|
68
|
+
id: this.id,
|
|
69
|
+
type: this.type,
|
|
70
|
+
counters: this.counters
|
|
71
|
+
};
|
|
72
|
+
};
|
|
121
73
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
74
|
+
proto.recover = function recover(state) {
|
|
75
|
+
Object.assign(this[countersSymbol], state.counters);
|
|
76
|
+
};
|
|
125
77
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
sourceElement.on('end', onSourceEnd, {
|
|
131
|
-
consumerTag: sourceEndConsumerTag
|
|
132
|
-
});
|
|
133
|
-
}
|
|
78
|
+
proto.getApi = function getApi() {
|
|
79
|
+
return this;
|
|
80
|
+
};
|
|
134
81
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
82
|
+
proto.activate = function activate() {
|
|
83
|
+
const sourceElement = this[sourceElementSymbol];
|
|
84
|
+
const safeId = (0, _shared.brokerSafeId)(this.id);
|
|
85
|
+
sourceElement.on('message', this.deactivate.bind(this), {
|
|
86
|
+
consumerTag: `_message-on-message-${safeId}`
|
|
87
|
+
});
|
|
88
|
+
sourceElement.on('end', this._onSourceEnd.bind(this), {
|
|
89
|
+
consumerTag: `_message-on-end-${safeId}`
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
proto.deactivate = function deactivate() {
|
|
94
|
+
const sourceElement = this[sourceElementSymbol];
|
|
95
|
+
const safeId = (0, _shared.brokerSafeId)(this.id);
|
|
96
|
+
sourceElement.broker.cancel(`_message-on-end-${safeId}`);
|
|
97
|
+
sourceElement.broker.cancel(`_message-on-message-${safeId}`);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
proto._onSourceEnd = function onSourceEnd({
|
|
101
|
+
content
|
|
102
|
+
}) {
|
|
103
|
+
++this[countersSymbol].messages;
|
|
104
|
+
const source = this.source;
|
|
105
|
+
const target = this.target;
|
|
106
|
+
this.logger.debug(`<${this.id}> sending message from <${source.processId}.${source.id}> to <${target.id ? `${target.processId}.${target.id}` : target.processId}>`);
|
|
107
|
+
this.broker.publish('event', 'message.outbound', this._createMessage(content.message));
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
proto._createMessage = function createMessage(message) {
|
|
111
|
+
return {
|
|
112
|
+
id: this.id,
|
|
113
|
+
type: this.type,
|
|
114
|
+
name: this.name,
|
|
115
|
+
source: { ...this.source
|
|
116
|
+
},
|
|
117
|
+
target: { ...this.target
|
|
118
|
+
},
|
|
119
|
+
parent: (0, _messageHelper.cloneParent)(this.parent),
|
|
120
|
+
message
|
|
121
|
+
};
|
|
122
|
+
};
|