@5minds/node-red-contrib-processcube 0.15.0-fix-error-in-process-instance-query-f9f0d2-lz03zzg4 → 0.15.0-fix-error-in-process-instance-query-8fa811-lz054xqa
Sign up to get free protection for your applications and to get access to all the features.
- package/Dockerfile +1 -1
- package/docker-compose.yml +12 -0
- package/examples/External-Task-Sample.json +252 -0
- package/externaltask-error.html +16 -2
- package/externaltask-error.js +11 -13
- package/externaltask-input.html +19 -2
- package/externaltask-input.js +107 -60
- package/externaltask-output.html +12 -2
- package/externaltask-output.js +8 -7
- package/message-event-trigger.js +6 -14
- package/nodered/node-red-contrib-processcube-flows.json +216 -132
- package/nodered/package.json +1 -0
- package/package.json +2 -2
- package/process-start.js +1 -13
- package/processcube-engine-config.js +14 -0
- package/processdefinition-query.js +6 -16
- package/processes/External-Task-Sample.bpmn +94 -0
- package/processinstance-query.js +6 -17
- package/signal-event-trigger.js +2 -12
- package/usertask-finished-listener.js +24 -27
- package/usertask-input.js +12 -26
- package/usertask-new-listener.js +5 -16
- package/usertask-output.js +8 -17
- package/processes/CheckError.bpmn +0 -78
- package/processes/NodeRedExternalTask.bpmn +0 -77
- package/processes/SampleUserTask.bpmn +0 -95
package/Dockerfile
CHANGED
package/docker-compose.yml
CHANGED
@@ -5,12 +5,17 @@ services:
|
|
5
5
|
context: .
|
6
6
|
ports:
|
7
7
|
- "1880:1880"
|
8
|
+
- "9229:9229"
|
8
9
|
environment:
|
9
10
|
- TZ=Europe/Berlin
|
10
11
|
- ENGINE_URL=http://engine:8000
|
11
12
|
- FLOWS=/nodered/node-red-contrib-processcube-flows.json
|
12
13
|
volumes:
|
13
14
|
- ./nodered/:/nodered/
|
15
|
+
- ./examples/:/examples/
|
16
|
+
depends_on:
|
17
|
+
- engine
|
18
|
+
- authority
|
14
19
|
|
15
20
|
engine:
|
16
21
|
image: 5minds/processcube_engine:2024-1
|
@@ -19,9 +24,16 @@ services:
|
|
19
24
|
volumes:
|
20
25
|
- ./processes:/processes:ro
|
21
26
|
environment:
|
27
|
+
application__name: Engine for Node-RED contrib
|
22
28
|
iam__baseUrl: http://authority:11560
|
23
29
|
iam__allowAnonymousRootAccess: true
|
24
30
|
command: --seed-dir=/processes --port 8000
|
31
|
+
depends_on:
|
32
|
+
- authority
|
33
|
+
healthcheck:
|
34
|
+
test: bash -c "[ -f /tmp/healthy ]"
|
35
|
+
timeout: 1s
|
36
|
+
retries: 20
|
25
37
|
|
26
38
|
authority:
|
27
39
|
image: 5minds/processcube_authority:3.0.4
|
@@ -0,0 +1,252 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": "a23d2e782beb66f4",
|
4
|
+
"type": "tab",
|
5
|
+
"label": "External Task Sample",
|
6
|
+
"disabled": false,
|
7
|
+
"info": "",
|
8
|
+
"env": []
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"id": "70d7a70e375b162a",
|
12
|
+
"type": "group",
|
13
|
+
"z": "a23d2e782beb66f4",
|
14
|
+
"style": {
|
15
|
+
"stroke": "#999999",
|
16
|
+
"stroke-opacity": "1",
|
17
|
+
"fill": "none",
|
18
|
+
"fill-opacity": "1",
|
19
|
+
"label": true,
|
20
|
+
"label-position": "nw",
|
21
|
+
"color": "#a4a4a4"
|
22
|
+
},
|
23
|
+
"nodes": [
|
24
|
+
"2991a5e6df2b87d2",
|
25
|
+
"911fde53bcbb7e3f",
|
26
|
+
"d56bb7cd73fd220c",
|
27
|
+
"15a5f64b9e2e05fc"
|
28
|
+
],
|
29
|
+
"x": 34,
|
30
|
+
"y": 79,
|
31
|
+
"w": 512,
|
32
|
+
"h": 142
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"id": "31cb6729aac0ba46",
|
36
|
+
"type": "group",
|
37
|
+
"z": "a23d2e782beb66f4",
|
38
|
+
"style": {
|
39
|
+
"stroke": "#999999",
|
40
|
+
"stroke-opacity": "1",
|
41
|
+
"fill": "none",
|
42
|
+
"fill-opacity": "1",
|
43
|
+
"label": true,
|
44
|
+
"label-position": "nw",
|
45
|
+
"color": "#a4a4a4"
|
46
|
+
},
|
47
|
+
"nodes": [
|
48
|
+
"18e05d562d48f32d",
|
49
|
+
"49aee03a7885fae8",
|
50
|
+
"e4555d9019cd3f47",
|
51
|
+
"bd68c4bdc53b8f80",
|
52
|
+
"fb87f79852b22e4a",
|
53
|
+
"1ba1e62c9935255f",
|
54
|
+
"b49f226ba865e164"
|
55
|
+
],
|
56
|
+
"x": 34,
|
57
|
+
"y": 259,
|
58
|
+
"w": 812,
|
59
|
+
"h": 202
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"id": "2991a5e6df2b87d2",
|
63
|
+
"type": "externaltask-input",
|
64
|
+
"z": "a23d2e782beb66f4",
|
65
|
+
"g": "70d7a70e375b162a",
|
66
|
+
"name": "Test",
|
67
|
+
"engine": "42e6796dddd9d4db",
|
68
|
+
"topic": "Test",
|
69
|
+
"x": 110,
|
70
|
+
"y": 180,
|
71
|
+
"wires": [
|
72
|
+
[
|
73
|
+
"d56bb7cd73fd220c"
|
74
|
+
]
|
75
|
+
]
|
76
|
+
},
|
77
|
+
{
|
78
|
+
"id": "911fde53bcbb7e3f",
|
79
|
+
"type": "externaltask-output",
|
80
|
+
"z": "a23d2e782beb66f4",
|
81
|
+
"g": "70d7a70e375b162a",
|
82
|
+
"name": "Test Ende",
|
83
|
+
"x": 460,
|
84
|
+
"y": 180,
|
85
|
+
"wires": []
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"id": "d56bb7cd73fd220c",
|
89
|
+
"type": "delay",
|
90
|
+
"z": "a23d2e782beb66f4",
|
91
|
+
"g": "70d7a70e375b162a",
|
92
|
+
"name": "",
|
93
|
+
"pauseType": "delay",
|
94
|
+
"timeout": "1",
|
95
|
+
"timeoutUnits": "seconds",
|
96
|
+
"rate": "1",
|
97
|
+
"nbRateUnits": "1",
|
98
|
+
"rateUnits": "second",
|
99
|
+
"randomFirst": "1",
|
100
|
+
"randomLast": "5",
|
101
|
+
"randomUnits": "seconds",
|
102
|
+
"drop": false,
|
103
|
+
"allowrate": false,
|
104
|
+
"outputs": 1,
|
105
|
+
"x": 280,
|
106
|
+
"y": 180,
|
107
|
+
"wires": [
|
108
|
+
[
|
109
|
+
"911fde53bcbb7e3f"
|
110
|
+
]
|
111
|
+
]
|
112
|
+
},
|
113
|
+
{
|
114
|
+
"id": "18e05d562d48f32d",
|
115
|
+
"type": "externaltask-input",
|
116
|
+
"z": "a23d2e782beb66f4",
|
117
|
+
"g": "31cb6729aac0ba46",
|
118
|
+
"name": "SampleError",
|
119
|
+
"engine": "42e6796dddd9d4db",
|
120
|
+
"topic": "SampleError",
|
121
|
+
"x": 130,
|
122
|
+
"y": 360,
|
123
|
+
"wires": [
|
124
|
+
[
|
125
|
+
"49aee03a7885fae8"
|
126
|
+
]
|
127
|
+
]
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"id": "49aee03a7885fae8",
|
131
|
+
"type": "delay",
|
132
|
+
"z": "a23d2e782beb66f4",
|
133
|
+
"g": "31cb6729aac0ba46",
|
134
|
+
"name": "",
|
135
|
+
"pauseType": "delay",
|
136
|
+
"timeout": "5",
|
137
|
+
"timeoutUnits": "seconds",
|
138
|
+
"rate": "1",
|
139
|
+
"nbRateUnits": "1",
|
140
|
+
"rateUnits": "second",
|
141
|
+
"randomFirst": "1",
|
142
|
+
"randomLast": "5",
|
143
|
+
"randomUnits": "seconds",
|
144
|
+
"drop": false,
|
145
|
+
"allowrate": false,
|
146
|
+
"outputs": 1,
|
147
|
+
"x": 320,
|
148
|
+
"y": 360,
|
149
|
+
"wires": [
|
150
|
+
[
|
151
|
+
"bd68c4bdc53b8f80"
|
152
|
+
]
|
153
|
+
]
|
154
|
+
},
|
155
|
+
{
|
156
|
+
"id": "e4555d9019cd3f47",
|
157
|
+
"type": "catch",
|
158
|
+
"z": "a23d2e782beb66f4",
|
159
|
+
"g": "31cb6729aac0ba46",
|
160
|
+
"name": "",
|
161
|
+
"scope": "group",
|
162
|
+
"uncaught": false,
|
163
|
+
"x": 510,
|
164
|
+
"y": 420,
|
165
|
+
"wires": [
|
166
|
+
[
|
167
|
+
"fb87f79852b22e4a"
|
168
|
+
]
|
169
|
+
]
|
170
|
+
},
|
171
|
+
{
|
172
|
+
"id": "bd68c4bdc53b8f80",
|
173
|
+
"type": "function",
|
174
|
+
"z": "a23d2e782beb66f4",
|
175
|
+
"g": "31cb6729aac0ba46",
|
176
|
+
"name": "raise Error",
|
177
|
+
"func": "throw Error(\"hello error\");\n\nreturn msg;",
|
178
|
+
"outputs": 1,
|
179
|
+
"timeout": 0,
|
180
|
+
"noerr": 0,
|
181
|
+
"initialize": "",
|
182
|
+
"finalize": "",
|
183
|
+
"libs": [],
|
184
|
+
"x": 510,
|
185
|
+
"y": 360,
|
186
|
+
"wires": [
|
187
|
+
[
|
188
|
+
"1ba1e62c9935255f"
|
189
|
+
]
|
190
|
+
]
|
191
|
+
},
|
192
|
+
{
|
193
|
+
"id": "fb87f79852b22e4a",
|
194
|
+
"type": "externaltask-error",
|
195
|
+
"z": "a23d2e782beb66f4",
|
196
|
+
"g": "31cb6729aac0ba46",
|
197
|
+
"name": "Send Error to Engine",
|
198
|
+
"error": "MyErrorCode",
|
199
|
+
"x": 720,
|
200
|
+
"y": 420,
|
201
|
+
"wires": [
|
202
|
+
[]
|
203
|
+
]
|
204
|
+
},
|
205
|
+
{
|
206
|
+
"id": "1ba1e62c9935255f",
|
207
|
+
"type": "externaltask-output",
|
208
|
+
"z": "a23d2e782beb66f4",
|
209
|
+
"g": "31cb6729aac0ba46",
|
210
|
+
"name": "",
|
211
|
+
"x": 710,
|
212
|
+
"y": 360,
|
213
|
+
"wires": []
|
214
|
+
},
|
215
|
+
{
|
216
|
+
"id": "15a5f64b9e2e05fc",
|
217
|
+
"type": "comment",
|
218
|
+
"z": "a23d2e782beb66f4",
|
219
|
+
"g": "70d7a70e375b162a",
|
220
|
+
"name": "Simple External Task handling",
|
221
|
+
"info": "",
|
222
|
+
"x": 180,
|
223
|
+
"y": 120,
|
224
|
+
"wires": []
|
225
|
+
},
|
226
|
+
{
|
227
|
+
"id": "b49f226ba865e164",
|
228
|
+
"type": "comment",
|
229
|
+
"z": "a23d2e782beb66f4",
|
230
|
+
"g": "31cb6729aac0ba46",
|
231
|
+
"name": "Error handling with external tasks",
|
232
|
+
"info": "",
|
233
|
+
"x": 190,
|
234
|
+
"y": 300,
|
235
|
+
"wires": []
|
236
|
+
},
|
237
|
+
{
|
238
|
+
"id": "799125e21de02f13",
|
239
|
+
"type": "comment",
|
240
|
+
"z": "a23d2e782beb66f4",
|
241
|
+
"name": "For Testing, deploy \"External-Task-Sample.bpmn\" and start the process.",
|
242
|
+
"info": "",
|
243
|
+
"x": 300,
|
244
|
+
"y": 40,
|
245
|
+
"wires": []
|
246
|
+
},
|
247
|
+
{
|
248
|
+
"id": "42e6796dddd9d4db",
|
249
|
+
"type": "processcube-engine-config",
|
250
|
+
"url": "http://engine:8000"
|
251
|
+
}
|
252
|
+
]
|
package/externaltask-error.html
CHANGED
@@ -26,6 +26,20 @@
|
|
26
26
|
</div>
|
27
27
|
</script>
|
28
28
|
|
29
|
-
<script type="text/
|
30
|
-
|
29
|
+
<script type="text/markdown" data-help-name="externaltask-error">
|
30
|
+
Used for reporting errors in the processing of external tasks. The error
|
31
|
+
code `Error` in the configuration is forwarded to the ProcessCube engine for
|
32
|
+
handling within *Error-Boundary-Events*.
|
33
|
+
|
34
|
+
## Inputs
|
35
|
+
|
36
|
+
: msg (Object) : Passed as `ErrorDetails` to the engine
|
37
|
+
: Error (string) : From the configuration
|
38
|
+
: Message (string) : The caught exception message
|
39
|
+
: StackTrace (string) : The stack trace of the exception
|
40
|
+
|
41
|
+
### References
|
42
|
+
|
43
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
44
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
31
45
|
</script>
|
package/externaltask-error.js
CHANGED
@@ -7,25 +7,23 @@ module.exports = function (RED) {
|
|
7
7
|
var eventEmitter = flowContext.get('emitter');
|
8
8
|
|
9
9
|
node.on('input', function (msg) {
|
10
|
-
const
|
10
|
+
const flowNodeInstanceId = msg.flowNodeInstanceId;
|
11
11
|
|
12
|
-
let
|
12
|
+
let msgError = msg.error;
|
13
13
|
|
14
|
-
if (
|
15
|
-
|
16
|
-
error.source = msg.payload;
|
14
|
+
if (msgError === undefined) {
|
15
|
+
msgError.message = "An error occurred";
|
17
16
|
}
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
errorMessage: error.message,
|
23
|
-
errorDetails: error.source,
|
24
|
-
},
|
25
|
-
};
|
18
|
+
const error = new Error(msgError.message);
|
19
|
+
error.errorCode = config.error;
|
20
|
+
error.errorDetails = RED.util.encodeObject(msg);
|
26
21
|
|
27
|
-
|
22
|
+
msg.errorCode = config.error;
|
23
|
+
msg.errorMessage = msgError.message;
|
28
24
|
|
25
|
+
eventEmitter.emit(`handle-${flowNodeInstanceId}`, error, true);
|
26
|
+
|
29
27
|
node.send(msg);
|
30
28
|
});
|
31
29
|
}
|
package/externaltask-input.html
CHANGED
@@ -31,6 +31,23 @@
|
|
31
31
|
</div>
|
32
32
|
</script>
|
33
33
|
|
34
|
-
<script type="text/
|
35
|
-
|
34
|
+
<script type="text/markdown" data-help-name="externaltask-input">
|
35
|
+
Waiting for external tasks that correspond to the `Topic` configured in
|
36
|
+
the connected ProcessCube Engine for processing.
|
37
|
+
|
38
|
+
## Outputs
|
39
|
+
|
40
|
+
: payload (string) : Defines the input of the external task token
|
41
|
+
: task (object) : The external task object
|
42
|
+
: flowNodeInstanceId : The Id of the external task, which is needed to complete the task
|
43
|
+
|
44
|
+
### Details
|
45
|
+
|
46
|
+
- To finish the external task the `externaltask-output` node is required.
|
47
|
+
- For handling a error while executing a flow as external task the `externaltask-error` node is required.
|
48
|
+
|
49
|
+
### References
|
50
|
+
|
51
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© Plattform
|
52
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED Integration in ProcessCube©
|
36
53
|
</script>
|
package/externaltask-input.js
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
const process = require('process');
|
2
1
|
const EventEmitter = require('node:events');
|
3
2
|
|
4
|
-
const engine_client = require('@5minds/processcube_engine_client');
|
5
|
-
|
6
3
|
function showStatus(node, msgCounter) {
|
7
4
|
if (msgCounter >= 1) {
|
8
5
|
node.status({ fill: 'blue', shape: 'dot', text: `handling tasks ${msgCounter}` });
|
@@ -11,34 +8,17 @@ function showStatus(node, msgCounter) {
|
|
11
8
|
}
|
12
9
|
}
|
13
10
|
|
14
|
-
|
15
|
-
msgCounter--;
|
16
|
-
|
17
|
-
if (msgCounter < 0) {
|
18
|
-
msgCounter = 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
return msgCounter;
|
22
|
-
}
|
11
|
+
const started_external_tasks = {};
|
23
12
|
|
24
13
|
module.exports = function (RED) {
|
25
14
|
function ExternalTaskInput(config) {
|
26
15
|
RED.nodes.createNode(this, config);
|
27
16
|
var node = this;
|
28
|
-
var msgCounter = 0;
|
29
17
|
var flowContext = node.context().flow;
|
30
|
-
var nodeContext = node.context();
|
31
18
|
|
32
19
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
33
20
|
|
34
|
-
const
|
35
|
-
|
36
|
-
var client = nodeContext.get('client');
|
37
|
-
|
38
|
-
if (!client) {
|
39
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
40
|
-
client = nodeContext.get('client');
|
41
|
-
}
|
21
|
+
const client = this.engine.getEngineClient();
|
42
22
|
|
43
23
|
var eventEmitter = flowContext.get('emitter');
|
44
24
|
|
@@ -47,54 +27,121 @@ module.exports = function (RED) {
|
|
47
27
|
eventEmitter = flowContext.get('emitter');
|
48
28
|
}
|
49
29
|
|
50
|
-
client.externalTasks
|
51
|
-
.subscribeToExternalTaskTopic(config.topic, async (payload, externalTask) => {
|
52
|
-
msgCounter++;
|
30
|
+
client.externalTasks.subscribeToExternalTaskTopic(config.topic, async (payload, externalTask) => {
|
53
31
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
32
|
+
const saveHandleCallback = (data, callback) => {
|
33
|
+
try {
|
34
|
+
callback(data);
|
35
|
+
} catch (error) {
|
36
|
+
node.error(`Error in callback 'saveHandleCallback': ${error.message}`);
|
37
|
+
}
|
38
|
+
};
|
58
39
|
|
59
|
-
|
60
|
-
resolve(result);
|
61
|
-
});
|
40
|
+
return await new Promise((resolve, reject) => {
|
62
41
|
|
63
|
-
|
64
|
-
|
65
|
-
showStatus(node, msgCounter);
|
42
|
+
const handleFinishTask = (msg) => {
|
43
|
+
let result = RED.util.encodeObject(msg.payload);
|
66
44
|
|
67
|
-
|
45
|
+
node.log(`handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* ${externalTask.processInstanceId} with result ${result} on msg._msgid ${msg._msgid}.`);
|
68
46
|
|
69
|
-
|
70
|
-
|
47
|
+
if (externalTask.flowNodeInstanceId) {
|
48
|
+
delete started_external_tasks[externalTask.flowNodeInstanceId];
|
49
|
+
}
|
71
50
|
|
72
|
-
showStatus(node,
|
51
|
+
showStatus(node, Object.keys(started_external_tasks).length);
|
73
52
|
|
74
|
-
node.send({
|
75
|
-
topic: externalTask.topic,
|
76
|
-
payload: payload,
|
77
|
-
externalTaskId: externalTask.flowNodeInstanceId,
|
78
|
-
});
|
79
|
-
});
|
80
|
-
})
|
81
|
-
.then(async (externalTaskWorker) => {
|
82
|
-
node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });
|
83
53
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
54
|
+
//resolve(result);
|
55
|
+
saveHandleCallback(result, resolve)
|
56
|
+
};
|
57
|
+
|
58
|
+
const handleErrorTask = (msg) => {
|
59
|
+
|
60
|
+
node.log(`handle error event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${msg._msgid}'.`);
|
61
|
+
|
62
|
+
if (externalTask.flowNodeInstanceId) {
|
63
|
+
delete started_external_tasks[externalTask.flowNodeInstanceId];
|
64
|
+
}
|
65
|
+
|
66
|
+
showStatus(node, Object.keys(started_external_tasks).length);
|
89
67
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
68
|
+
|
69
|
+
// TODO: with reject, the default error handling is proceed
|
70
|
+
// SEE: https://github.com/5minds/ProcessCube.Engine.Client.ts/blob/develop/src/ExternalTaskWorker.ts#L180
|
71
|
+
// reject(result);
|
72
|
+
//resolve(msg);
|
73
|
+
saveHandleCallback(msg, resolve);
|
74
|
+
};
|
75
|
+
|
76
|
+
eventEmitter.once(`handle-${externalTask.flowNodeInstanceId}`, (msg, isError = false) => {
|
77
|
+
node.log(`handle event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}' and *isError* '${isError}'`);
|
78
|
+
|
79
|
+
if (isError) {
|
80
|
+
handleErrorTask(msg);
|
81
|
+
} else {
|
82
|
+
handleFinishTask(msg);
|
95
83
|
}
|
96
84
|
});
|
85
|
+
|
86
|
+
started_external_tasks[externalTask.flowNodeInstanceId] = externalTask;
|
87
|
+
|
88
|
+
showStatus(node, Object.keys(started_external_tasks).length);
|
89
|
+
|
90
|
+
let msg = {
|
91
|
+
_msgid: RED.util.generateId(),
|
92
|
+
task: RED.util.encodeObject(externalTask),
|
93
|
+
payload: payload,
|
94
|
+
flowNodeInstanceId: externalTask.flowNodeInstanceId
|
95
|
+
};
|
96
|
+
|
97
|
+
node.log(`Received *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' with *msg._msgid* '${msg._msgid}'`);
|
98
|
+
|
99
|
+
node.send(msg);
|
97
100
|
});
|
101
|
+
})
|
102
|
+
.then(async (externalTaskWorker) => {
|
103
|
+
node.status({ fill: 'blue', shape: 'ring', text: 'subcribed' });
|
104
|
+
|
105
|
+
externalTaskWorker.identity = node.server.identity;
|
106
|
+
node.server.registerOnIdentityChanged((identity) => {
|
107
|
+
externalTaskWorker.identity = identity;
|
108
|
+
});
|
109
|
+
|
110
|
+
// export type WorkerErrorHandler = (errorType: 'fetchAndLock' | 'extendLock' | 'processExternalTask' | 'finishExternalTask', error: Error, externalTask?: ExternalTask<any>) => void;
|
111
|
+
externalTaskWorker.onWorkerError((errorType, error, externalTask) => {
|
112
|
+
switch (errorType) {
|
113
|
+
case 'extendLock':
|
114
|
+
case 'finishExternalTask':
|
115
|
+
case 'processExternalTask':
|
116
|
+
node.error(`Worker error ${errorType} for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}': ${error.message}`);
|
117
|
+
|
118
|
+
if (externalTask) {
|
119
|
+
delete started_external_tasks[externalTask.flowNodeInstanceId];
|
120
|
+
}
|
121
|
+
|
122
|
+
showStatus(node, Object.keys(started_external_tasks).length);
|
123
|
+
break;
|
124
|
+
default:
|
125
|
+
node.error(`Worker error ${errorType}: ${error.message}`);
|
126
|
+
break;
|
127
|
+
}
|
128
|
+
});
|
129
|
+
|
130
|
+
try {
|
131
|
+
externalTaskWorker.start();
|
132
|
+
} catch (error) {
|
133
|
+
node.error(`Worker start 'externalTaskWorker.start' failed: ${error.message}`);
|
134
|
+
}
|
135
|
+
|
136
|
+
node.on("close", () => {
|
137
|
+
try {
|
138
|
+
externalTaskWorker.stop();
|
139
|
+
} catch {
|
140
|
+
node.error('Client close failed');
|
141
|
+
}
|
142
|
+
});
|
143
|
+
});
|
98
144
|
}
|
99
|
-
|
100
|
-
|
145
|
+
|
146
|
+
RED.nodes.registerType("externaltask-input", ExternalTaskInput);
|
147
|
+
}
|
package/externaltask-output.html
CHANGED
@@ -21,6 +21,16 @@
|
|
21
21
|
</div>
|
22
22
|
</script>
|
23
23
|
|
24
|
-
<script type="text/
|
25
|
-
|
24
|
+
<script type="text/markdown" data-help-name="externaltask-output">
|
25
|
+
Used to complete the external task. The `msg.payload` is returned to the ProcessCube
|
26
|
+
engine as the result of the external task.
|
27
|
+
|
28
|
+
## Inputs
|
29
|
+
|
30
|
+
: payload (Object) : Returned to the ProcessCube engine as the result of the external task
|
31
|
+
|
32
|
+
### References
|
33
|
+
|
34
|
+
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
|
35
|
+
- [Node-RED Integration in ProcessCube©](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube©
|
26
36
|
</script>
|
package/externaltask-output.js
CHANGED
@@ -6,15 +6,16 @@ module.exports = function (RED) {
|
|
6
6
|
var flowContext = node.context().flow;
|
7
7
|
var eventEmitter = flowContext.get('emitter');
|
8
8
|
|
9
|
-
node.on('input', function
|
10
|
-
|
9
|
+
node.on('input', function(msg) {
|
10
|
+
|
11
|
+
const flowNodeInstanceId = msg.flowNodeInstanceId;
|
11
12
|
|
12
|
-
if (!
|
13
|
-
|
14
|
-
}
|
13
|
+
if (!flowNodeInstanceId) {
|
14
|
+
node.error('Error: The message did not contain the required external task id.', msg);
|
15
|
+
}
|
15
16
|
|
16
|
-
eventEmitter.emit(`
|
17
|
-
});
|
17
|
+
eventEmitter.emit(`handle-${flowNodeInstanceId}`, msg, false);
|
18
|
+
});
|
18
19
|
}
|
19
20
|
RED.nodes.registerType('externaltask-output', ExternalTaskOutput);
|
20
21
|
};
|
package/message-event-trigger.js
CHANGED
@@ -1,23 +1,11 @@
|
|
1
|
-
const process = require('process');
|
2
|
-
|
3
|
-
const engine_client = require('@5minds/processcube_engine_client');
|
4
|
-
|
5
1
|
module.exports = function (RED) {
|
6
2
|
function MessageEventTrigger(config) {
|
7
3
|
RED.nodes.createNode(this, config);
|
8
4
|
var node = this;
|
9
|
-
var nodeContext = node.context();
|
10
5
|
|
11
6
|
this.engine = this.server = RED.nodes.getNode(config.engine);
|
12
7
|
|
13
|
-
const
|
14
|
-
|
15
|
-
var client = nodeContext.get('client');
|
16
|
-
|
17
|
-
if (!client) {
|
18
|
-
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
19
|
-
client = nodeContext.get('client');
|
20
|
-
}
|
8
|
+
const client = this.engine.getEngineClient();
|
21
9
|
|
22
10
|
node.on('input', function (msg) {
|
23
11
|
client.events
|
@@ -30,7 +18,11 @@ module.exports = function (RED) {
|
|
30
18
|
msg.payload = result;
|
31
19
|
|
32
20
|
node.send(msg);
|
33
|
-
node.status({
|
21
|
+
node.status({
|
22
|
+
fill: 'blue',
|
23
|
+
shape: 'dot',
|
24
|
+
text: `message event triggered`,
|
25
|
+
});
|
34
26
|
})
|
35
27
|
.catch((error) => {
|
36
28
|
node.error(error);
|