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,132 +3,173 @@ import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecuti
|
|
|
3
3
|
import {cloneContent, cloneMessage} from '../messageHelper';
|
|
4
4
|
import {brokerSafeId} from '../shared';
|
|
5
5
|
|
|
6
|
+
const attachedTagsSymbol = Symbol.for('attachedConsumers');
|
|
7
|
+
const completeContentSymbol = Symbol.for('completeContent');
|
|
8
|
+
const executeMessageSymbol = Symbol.for('executeMessage');
|
|
9
|
+
const executionSymbol = Symbol.for('execution');
|
|
10
|
+
const shovelsSymbol = Symbol.for('shovels');
|
|
11
|
+
|
|
6
12
|
export default function BoundaryEvent(activityDef, context) {
|
|
7
|
-
return Activity(BoundaryEventBehaviour, activityDef, context);
|
|
13
|
+
return new Activity(BoundaryEventBehaviour, activityDef, context);
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
export function BoundaryEventBehaviour(activity) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
cancelActivity,
|
|
22
|
-
execute,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
function execute(executeMessage) {
|
|
26
|
-
const executeContent = cloneContent(executeMessage.content);
|
|
27
|
-
const {isRootScope, executionId, inbound} = executeContent;
|
|
28
|
-
|
|
29
|
-
let parentExecutionId, completeContent;
|
|
30
|
-
const errorConsumerTags = [];
|
|
31
|
-
const shovels = [];
|
|
32
|
-
if (isRootScope) {
|
|
33
|
-
parentExecutionId = executionId;
|
|
34
|
-
if (eventDefinitionExecution && !environment.settings.strict) {
|
|
35
|
-
broker.subscribeTmp('execution', 'execute.expect', onExpectMessage, {noAck: true, consumerTag: '_expect-tag'});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
attachedTo.broker.subscribeTmp('event', 'activity.leave', onAttachedLeave, {noAck: true, consumerTag: `_bound-listener-${parentExecutionId}`, priority: 300});
|
|
39
|
-
|
|
40
|
-
broker.subscribeOnce('execution', 'execute.detach', onDetachMessage, {consumerTag: '_detach-tag'});
|
|
41
|
-
broker.subscribeOnce('api', `activity.#.${parentExecutionId}`, onApiMessage, {consumerTag: `_api-${parentExecutionId}`});
|
|
42
|
-
broker.subscribeOnce('execution', 'execute.bound.completed', onCompleted, {consumerTag: `_execution-completed-${parentExecutionId}`});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (eventDefinitionExecution) eventDefinitionExecution.execute(executeMessage);
|
|
46
|
-
|
|
47
|
-
function onCompleted(_, message) {
|
|
48
|
-
if (!cancelActivity && !message.content.cancelActivity) {
|
|
49
|
-
stop();
|
|
50
|
-
return broker.publish('execution', 'execute.completed', cloneContent(message.content));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
completeContent = message.content;
|
|
54
|
-
|
|
55
|
-
const attachedToContent = inbound && inbound[0];
|
|
56
|
-
logger.debug(`<${executionId} (id)> cancel ${attachedTo.status} activity <${attachedToContent.executionId} (${attachedToContent.id})>`);
|
|
57
|
-
|
|
58
|
-
attachedTo.getApi({content: attachedToContent}).discard();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function onAttachedLeave(routingKey, message) {
|
|
62
|
-
if (message.content.id !== attachedToId) return;
|
|
63
|
-
stop();
|
|
64
|
-
if (!completeContent) return broker.publish('execution', 'execute.discard', executeContent);
|
|
65
|
-
return broker.publish('execution', 'execute.completed', completeContent);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function onExpectMessage(_, message) {
|
|
69
|
-
const errorConsumerTag = `_bound-error-listener-${message.content.executionId}`;
|
|
70
|
-
errorConsumerTags.push(errorConsumerTag);
|
|
71
|
-
attachedTo.broker.subscribeTmp('event', 'activity.error', attachedErrorHandler(message.content.expectRoutingKey), {noAck: true, consumerTag: errorConsumerTag, priority: 300});
|
|
72
|
-
}
|
|
17
|
+
this.id = activity.id;
|
|
18
|
+
this.type = activity.type;
|
|
19
|
+
this.attachedTo = activity.attachedTo;
|
|
20
|
+
this.activity = activity;
|
|
21
|
+
this.environment = activity.environment;
|
|
22
|
+
this.broker = activity.broker;
|
|
23
|
+
this[executionSymbol] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions, 'execute.bound.completed');
|
|
24
|
+
this[shovelsSymbol] = [];
|
|
25
|
+
this[attachedTagsSymbol] = [];
|
|
26
|
+
}
|
|
73
27
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
28
|
+
const proto = BoundaryEventBehaviour.prototype;
|
|
29
|
+
|
|
30
|
+
Object.defineProperty(proto, 'executionId', {
|
|
31
|
+
get() {
|
|
32
|
+
const message = this[executeMessageSymbol];
|
|
33
|
+
return message && message.content.executionId;
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
Object.defineProperty(proto, 'cancelActivity', {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get() {
|
|
40
|
+
const behaviour = this.activity.behaviour || {};
|
|
41
|
+
return 'cancelActivity' in behaviour ? behaviour.cancelActivity : true;
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
proto.execute = function execute(executeMessage) {
|
|
46
|
+
const {isRootScope, executionId} = executeMessage.content;
|
|
47
|
+
|
|
48
|
+
const eventDefinitionExecution = this[executionSymbol];
|
|
49
|
+
if (isRootScope) {
|
|
50
|
+
this[executeMessageSymbol] = executeMessage;
|
|
51
|
+
|
|
52
|
+
const broker = this.broker;
|
|
53
|
+
if (eventDefinitionExecution && !this.environment.settings.strict) {
|
|
54
|
+
broker.subscribeTmp('execution', 'execute.expect', this._onExpectMessage.bind(this), {
|
|
55
|
+
noAck: true,
|
|
56
|
+
consumerTag: '_expect-tag',
|
|
57
|
+
});
|
|
79
58
|
}
|
|
80
59
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
60
|
+
const consumerTag = `_bound-listener-${executionId}`;
|
|
61
|
+
this.attachedTo.broker.subscribeTmp('event', 'activity.leave', this._onAttachedLeave.bind(this), {
|
|
62
|
+
noAck: true,
|
|
63
|
+
consumerTag,
|
|
64
|
+
priority: 300,
|
|
65
|
+
});
|
|
66
|
+
this[attachedTagsSymbol].push(consumerTag);
|
|
67
|
+
|
|
68
|
+
broker.subscribeOnce('execution', 'execute.detach', this._onDetachMessage.bind(this), {
|
|
69
|
+
consumerTag: '_detach-tag',
|
|
70
|
+
});
|
|
71
|
+
broker.subscribeOnce('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
|
|
72
|
+
consumerTag: `_api-${executionId}`,
|
|
73
|
+
});
|
|
74
|
+
broker.subscribeOnce('execution', 'execute.bound.completed', this._onCompleted.bind(this), {
|
|
75
|
+
consumerTag: `_execution-completed-${executionId}`,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
98
78
|
|
|
99
|
-
|
|
100
|
-
|
|
79
|
+
if (eventDefinitionExecution) {
|
|
80
|
+
return eventDefinitionExecution.execute(executeMessage);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
101
83
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
84
|
+
proto._onCompleted = function onCompleted(_, {content}) {
|
|
85
|
+
if (!this.cancelActivity && !content.cancelActivity) {
|
|
86
|
+
this._stop();
|
|
87
|
+
return this.broker.publish('execution', 'execute.completed', cloneContent(content));
|
|
88
|
+
}
|
|
106
89
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
90
|
+
this[completeContentSymbol] = content;
|
|
91
|
+
|
|
92
|
+
const {inbound} = this[executeMessageSymbol].content;
|
|
93
|
+
const attachedToContent = inbound && inbound[0];
|
|
94
|
+
const attachedTo = this.attachedTo;
|
|
95
|
+
this.activity.logger.debug(`<${this.executionId} (${this.id})> cancel ${attachedTo.status} activity <${attachedToContent.executionId} (${attachedToContent.id})>`);
|
|
96
|
+
|
|
97
|
+
attachedTo.getApi({content: attachedToContent}).discard();
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
proto._onAttachedLeave = function onAttachedLeave(_, {content}) {
|
|
101
|
+
if (content.id !== this.attachedTo.id) return;
|
|
102
|
+
this._stop();
|
|
103
|
+
const completeContent = this[completeContentSymbol];
|
|
104
|
+
if (!completeContent) return this.broker.publish('execution', 'execute.discard', this[executeMessageSymbol].content);
|
|
105
|
+
return this.broker.publish('execution', 'execute.completed', cloneContent(completeContent));
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
proto._onExpectMessage = function onExpectMessage(_, {content}) {
|
|
109
|
+
const {executionId, expectRoutingKey} = content;
|
|
110
|
+
const attachedTo = this.attachedTo;
|
|
111
|
+
|
|
112
|
+
const errorConsumerTag = `_bound-error-listener-${executionId}`;
|
|
113
|
+
this[attachedTagsSymbol].push(errorConsumerTag);
|
|
114
|
+
|
|
115
|
+
attachedTo.broker.subscribeTmp('event', 'activity.error', (__, errorMessage) => {
|
|
116
|
+
if (errorMessage.content.id !== attachedTo.id) return;
|
|
117
|
+
this.broker.publish('execution', expectRoutingKey, cloneContent(errorMessage.content));
|
|
118
|
+
}, {
|
|
119
|
+
noAck: true,
|
|
120
|
+
consumerTag: errorConsumerTag,
|
|
121
|
+
priority: 300,
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
proto._onDetachMessage = function onDetachMessage(_, {content}) {
|
|
126
|
+
const id = this.id, executionId = this.executionId, attachedTo = this.attachedTo;
|
|
127
|
+
this.activity.logger.debug(`<${executionId} (${id})> detach from activity <${attachedTo.id}>`);
|
|
128
|
+
this._stop(true);
|
|
129
|
+
|
|
130
|
+
const {executionId: detachId, bindExchange, sourceExchange, sourcePattern} = content;
|
|
131
|
+
|
|
132
|
+
const shovelName = `_detached-${brokerSafeId(id)}_${detachId}`;
|
|
133
|
+
this[shovelsSymbol].push(shovelName);
|
|
134
|
+
|
|
135
|
+
const broker = this.broker;
|
|
136
|
+
attachedTo.broker.createShovel(shovelName, {
|
|
137
|
+
exchange: sourceExchange,
|
|
138
|
+
pattern: sourcePattern,
|
|
139
|
+
}, {
|
|
140
|
+
broker,
|
|
141
|
+
exchange: bindExchange,
|
|
142
|
+
}, {
|
|
143
|
+
cloneMessage,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
broker.subscribeOnce('execution', 'execute.bound.completed', (__, {content: completeContent}) => {
|
|
147
|
+
this._stop();
|
|
148
|
+
this.broker.publish('execution', 'execute.completed', cloneContent(completeContent));
|
|
149
|
+
}, {
|
|
150
|
+
consumerTag: `_execution-completed-${executionId}`,
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
proto._onApiMessage = function onApiMessage(_, message) {
|
|
155
|
+
switch (message.properties.type) {
|
|
156
|
+
case 'discard':
|
|
157
|
+
case 'stop':
|
|
158
|
+
this._stop();
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
118
162
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
shovels.splice(0).forEach((shovelName) => attachedTo.broker.closeShovel(shovelName));
|
|
163
|
+
proto._stop = function stop(detach) {
|
|
164
|
+
const attachedTo = this.attachedTo, broker = this.broker, executionId = this.executionId;
|
|
165
|
+
for (const tag of this[attachedTagsSymbol].splice(0)) attachedTo.broker.cancel(tag);
|
|
166
|
+
for (const shovelName of this[shovelsSymbol].splice(0)) attachedTo.broker.closeShovel(shovelName);
|
|
124
167
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
168
|
+
broker.cancel('_expect-tag');
|
|
169
|
+
broker.cancel('_detach-tag');
|
|
170
|
+
broker.cancel(`_execution-completed-${executionId}`);
|
|
128
171
|
|
|
129
|
-
|
|
172
|
+
if (detach) return;
|
|
130
173
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
}
|
|
174
|
+
broker.cancel(`_api-${executionId}`);
|
|
175
|
+
};
|
package/src/events/EndEvent.js
CHANGED
|
@@ -2,27 +2,24 @@ import Activity from '../activity/Activity';
|
|
|
2
2
|
import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution';
|
|
3
3
|
import {cloneContent} from '../messageHelper';
|
|
4
4
|
|
|
5
|
+
const executionSymbol = Symbol.for('execution');
|
|
6
|
+
|
|
5
7
|
export default function EndEvent(activityDef, context) {
|
|
6
|
-
return Activity(EndEventBehaviour, {...activityDef, isThrowing: true}, context);
|
|
8
|
+
return new Activity(EndEventBehaviour, {...activityDef, isThrowing: true}, context);
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export function EndEventBehaviour(activity) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type,
|
|
16
|
-
execute,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return source;
|
|
20
|
-
|
|
21
|
-
function execute(executeMessage) {
|
|
22
|
-
if (eventDefinitionExecution) {
|
|
23
|
-
return eventDefinitionExecution.execute(executeMessage);
|
|
24
|
-
}
|
|
12
|
+
this.id = activity.id;
|
|
13
|
+
this.type = activity.type;
|
|
14
|
+
this.broker = activity.broker;
|
|
15
|
+
this[executionSymbol] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions);
|
|
16
|
+
}
|
|
25
17
|
|
|
26
|
-
|
|
18
|
+
EndEventBehaviour.prototype.execute = function execute(executeMessage) {
|
|
19
|
+
const execution = this[executionSymbol];
|
|
20
|
+
if (execution) {
|
|
21
|
+
return execution.execute(executeMessage);
|
|
27
22
|
}
|
|
28
|
-
|
|
23
|
+
|
|
24
|
+
return this.broker.publish('execution', 'execute.completed', cloneContent(executeMessage.content));
|
|
25
|
+
};
|
|
@@ -2,57 +2,53 @@ import Activity from '../activity/Activity';
|
|
|
2
2
|
import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution';
|
|
3
3
|
import {cloneContent} from '../messageHelper';
|
|
4
4
|
|
|
5
|
+
const executionSymbol = Symbol.for('execution');
|
|
6
|
+
|
|
5
7
|
export default function IntermediateCatchEvent(activityDef, context) {
|
|
6
|
-
return Activity(IntermediateCatchEventBehaviour, activityDef, context);
|
|
8
|
+
return new Activity(IntermediateCatchEventBehaviour, activityDef, context);
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export function IntermediateCatchEventBehaviour(activity) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type,
|
|
16
|
-
execute,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return source;
|
|
20
|
-
|
|
21
|
-
function execute(executeMessage) {
|
|
22
|
-
if (eventDefinitionExecution) {
|
|
23
|
-
return eventDefinitionExecution.execute(executeMessage);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const content = cloneContent(executeMessage.content);
|
|
27
|
-
const {executionId} = content;
|
|
28
|
-
broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {noAck: true, consumerTag: `_api-${executionId}`});
|
|
12
|
+
this.id = activity.id;
|
|
13
|
+
this.type = activity.type;
|
|
14
|
+
this.broker = activity.broker;
|
|
15
|
+
this[executionSymbol] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions);
|
|
16
|
+
}
|
|
29
17
|
|
|
30
|
-
|
|
18
|
+
IntermediateCatchEventBehaviour.prototype.execute = function execute(executeMessage) {
|
|
19
|
+
const execution = this[executionSymbol];
|
|
20
|
+
if (execution) {
|
|
21
|
+
return execution.execute(executeMessage);
|
|
22
|
+
}
|
|
31
23
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
24
|
+
const executeContent = executeMessage.content;
|
|
25
|
+
const executionId = executeContent.executionId;
|
|
26
|
+
const broker = this.broker;
|
|
27
|
+
broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this, executeMessage), {
|
|
28
|
+
noAck: true,
|
|
29
|
+
consumerTag: '_api-behaviour-execution',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return broker.publish('event', 'activity.wait', cloneContent(executeContent));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
IntermediateCatchEventBehaviour.prototype._onApiMessage = function onApiMessage(executeMessage, routingKey, message) {
|
|
36
|
+
switch (message.properties.type) {
|
|
37
|
+
case 'message':
|
|
38
|
+
case 'signal': {
|
|
39
|
+
const broker = this.broker;
|
|
40
|
+
broker.cancel('_api-behaviour-execution');
|
|
41
|
+
return broker.publish('execution', 'execute.completed', cloneContent(executeMessage.content, {
|
|
42
|
+
output: message.content.message,
|
|
43
|
+
}));
|
|
47
44
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return broker.publish('execution', 'execute.
|
|
45
|
+
case 'discard': {
|
|
46
|
+
const broker = this.broker;
|
|
47
|
+
broker.cancel('_api-behaviour-execution');
|
|
48
|
+
return broker.publish('execution', 'execute.discard', cloneContent(executeMessage.content));
|
|
52
49
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
broker.cancel(`_api-${executionId}`);
|
|
50
|
+
case 'stop': {
|
|
51
|
+
return this.broker.cancel('_api-behaviour-execution');
|
|
56
52
|
}
|
|
57
53
|
}
|
|
58
|
-
}
|
|
54
|
+
};
|
|
@@ -2,27 +2,24 @@ import Activity from '../activity/Activity';
|
|
|
2
2
|
import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution';
|
|
3
3
|
import {cloneContent} from '../messageHelper';
|
|
4
4
|
|
|
5
|
+
const executionSymbol = Symbol.for('execution');
|
|
6
|
+
|
|
5
7
|
export default function IntermediateThrowEvent(activityDef, context) {
|
|
6
|
-
return Activity(IntermediateThrowEventBehaviour, {...activityDef, isThrowing: true}, context);
|
|
8
|
+
return new Activity(IntermediateThrowEventBehaviour, {...activityDef, isThrowing: true}, context);
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export function IntermediateThrowEventBehaviour(activity) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type,
|
|
16
|
-
execute,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return source;
|
|
20
|
-
|
|
21
|
-
function execute(executeMessage) {
|
|
22
|
-
if (eventDefinitionExecution) {
|
|
23
|
-
return eventDefinitionExecution.execute(executeMessage);
|
|
24
|
-
}
|
|
12
|
+
this.id = activity.id;
|
|
13
|
+
this.type = activity.type;
|
|
14
|
+
this.broker = activity.broker;
|
|
15
|
+
this[executionSymbol] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions);
|
|
16
|
+
}
|
|
25
17
|
|
|
26
|
-
|
|
18
|
+
IntermediateThrowEventBehaviour.prototype.execute = function execute(executeMessage) {
|
|
19
|
+
const execution = this[executionSymbol];
|
|
20
|
+
if (execution) {
|
|
21
|
+
return execution.execute(executeMessage);
|
|
27
22
|
}
|
|
28
|
-
|
|
23
|
+
|
|
24
|
+
return this.broker.publish('execution', 'execute.completed', cloneContent(executeMessage.content));
|
|
25
|
+
};
|
package/src/events/StartEvent.js
CHANGED
|
@@ -2,68 +2,102 @@ import Activity from '../activity/Activity';
|
|
|
2
2
|
import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution';
|
|
3
3
|
import {cloneContent} from '../messageHelper';
|
|
4
4
|
|
|
5
|
+
const executeMessageSymbol = Symbol.for('executeMessage');
|
|
6
|
+
const executionSymbol = Symbol.for('execution');
|
|
7
|
+
|
|
5
8
|
export default function StartEvent(activityDef, context) {
|
|
6
|
-
return Activity(StartEventBehaviour, activityDef, context);
|
|
9
|
+
return new Activity(StartEventBehaviour, activityDef, context);
|
|
7
10
|
}
|
|
8
11
|
|
|
9
12
|
export function StartEventBehaviour(activity) {
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
this.id = activity.id;
|
|
14
|
+
this.type = activity.type;
|
|
15
|
+
this.activity = activity;
|
|
16
|
+
this.broker = activity.broker;
|
|
17
|
+
this[executionSymbol] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions);
|
|
18
|
+
}
|
|
12
19
|
|
|
13
|
-
|
|
14
|
-
id,
|
|
15
|
-
type,
|
|
16
|
-
execute,
|
|
17
|
-
};
|
|
20
|
+
const proto = StartEventBehaviour.prototype;
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
Object.defineProperty(proto, 'executionId', {
|
|
23
|
+
get() {
|
|
24
|
+
const message = this[executeMessageSymbol];
|
|
25
|
+
return message && message.content.executionId;
|
|
26
|
+
},
|
|
27
|
+
});
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
proto.execute = function execute(executeMessage) {
|
|
30
|
+
const execution = this[executionSymbol];
|
|
31
|
+
if (execution) {
|
|
32
|
+
return execution.execute(executeMessage);
|
|
33
|
+
}
|
|
25
34
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
const content = cloneContent(executeMessage.content);
|
|
36
|
+
const broker = this.broker;
|
|
37
|
+
if (!content.form) {
|
|
38
|
+
return broker.publish('execution', 'execute.completed', content);
|
|
39
|
+
}
|
|
30
40
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
const executionId = content.executionId;
|
|
42
|
+
this[executeMessageSymbol] = executeMessage;
|
|
43
|
+
broker.subscribeTmp('api', `activity.#.${executionId}`, (...args) => this._onApiMessage(...args), {
|
|
44
|
+
noAck: true,
|
|
45
|
+
consumerTag: `_api-${executionId}`,
|
|
46
|
+
priority: 300,
|
|
47
|
+
});
|
|
48
|
+
broker.subscribeTmp('api', '#.signal.*', (...args) => this._onDelegatedApiMessage(...args), {
|
|
49
|
+
noAck: true,
|
|
50
|
+
consumerTag: `_api-delegated-${executionId}`,
|
|
51
|
+
});
|
|
52
|
+
broker.publish('event', 'activity.wait', {...content, executionId, state: 'wait'});
|
|
53
|
+
};
|
|
35
54
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
56
|
+
const {type: messageType, correlationId} = message.properties;
|
|
57
|
+
switch (messageType) {
|
|
58
|
+
case 'stop':
|
|
59
|
+
return this._stop();
|
|
60
|
+
case 'signal': {
|
|
61
|
+
this._stop();
|
|
62
|
+
const content = this[executeMessageSymbol].content;
|
|
63
|
+
return this.broker.publish('execution', 'execute.completed', cloneContent(content, {
|
|
64
|
+
output: message.content.message,
|
|
65
|
+
state: 'signal',
|
|
66
|
+
}), {correlationId});
|
|
67
|
+
}
|
|
68
|
+
case 'discard': {
|
|
69
|
+
this._stop();
|
|
70
|
+
const content = this[executeMessageSymbol].content;
|
|
71
|
+
return this.broker.publish('execution', 'execute.discard', cloneContent(content), {correlationId});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
40
75
|
|
|
41
|
-
|
|
42
|
-
|
|
76
|
+
proto._onDelegatedApiMessage = function onDelegatedApiMessage(routingKey, message) {
|
|
77
|
+
if (!message.properties.delegate) return;
|
|
43
78
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return onApiMessage(routingKey, message);
|
|
47
|
-
}
|
|
79
|
+
const content = message.content;
|
|
80
|
+
if (!content.message) return;
|
|
48
81
|
|
|
49
|
-
|
|
50
|
-
|
|
82
|
+
const {id: signalId, executionId: signalExecutionId} = content.message;
|
|
83
|
+
if (signalId !== this.id && signalExecutionId !== this.executionId) return;
|
|
51
84
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
85
|
+
const {type, correlationId} = message.properties;
|
|
86
|
+
const executeContent = this[executeMessageSymbol].content;
|
|
87
|
+
this.broker.publish('event', 'activity.consumed', cloneContent(executeContent, {
|
|
88
|
+
message: {
|
|
89
|
+
...content.message,
|
|
90
|
+
},
|
|
91
|
+
}), {
|
|
92
|
+
correlationId,
|
|
93
|
+
type,
|
|
94
|
+
});
|
|
63
95
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
96
|
+
return this._onApiMessage(routingKey, message);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
proto._stop = function stop() {
|
|
100
|
+
const broker = this.broker, executionId = this.executionId;
|
|
101
|
+
broker.cancel(`_api-${executionId}`);
|
|
102
|
+
broker.cancel(`_api-delegated-${executionId}`);
|
|
103
|
+
};
|