@5minds/node-red-contrib-processcube-amqp 0.5.0 → 0.6.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/.node-red/data/.config.nodes.json +24 -2
- package/.node-red/data/.config.nodes.json.backup +13 -2
- package/.node-red/data/.config.users.json +1 -1
- package/.node-red/data/.config.users.json.backup +3 -0
- package/.node-red/data/.flows.json.backup +130 -2
- package/.node-red/data/flows.json +128 -1
- package/amqp-config.js +5 -0
- package/amqp-input.js +2 -7
- package/amqp-intermediate-input.html +74 -0
- package/amqp-intermediate-input.js +61 -0
- package/amqp-intermediate-output.html +69 -0
- package/amqp-intermediate-output.js +29 -0
- package/amqp-output.js +2 -3
- package/package.json +3 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"node-red": {
|
|
3
3
|
"name": "node-red",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.3",
|
|
5
5
|
"local": false,
|
|
6
6
|
"user": false,
|
|
7
7
|
"nodes": {
|
|
@@ -429,7 +429,7 @@
|
|
|
429
429
|
},
|
|
430
430
|
"@5minds/node-red-contrib-processcube-amqp": {
|
|
431
431
|
"name": "@5minds/node-red-contrib-processcube-amqp",
|
|
432
|
-
"version": "0.
|
|
432
|
+
"version": "0.5.0",
|
|
433
433
|
"local": true,
|
|
434
434
|
"user": false,
|
|
435
435
|
"nodes": {
|
|
@@ -444,6 +444,28 @@
|
|
|
444
444
|
"module": "@5minds/node-red-contrib-processcube-amqp",
|
|
445
445
|
"file": "/data/node_modules/node-red-contrib-processcube-amqp/amqp-input.js"
|
|
446
446
|
},
|
|
447
|
+
"amqpIntermediateInput": {
|
|
448
|
+
"name": "amqpIntermediateInput",
|
|
449
|
+
"types": [
|
|
450
|
+
"amqp-intermediate-input"
|
|
451
|
+
],
|
|
452
|
+
"enabled": true,
|
|
453
|
+
"local": true,
|
|
454
|
+
"user": false,
|
|
455
|
+
"module": "@5minds/node-red-contrib-processcube-amqp",
|
|
456
|
+
"file": "/data/node_modules/node-red-contrib-processcube-amqp/amqp-intermediate-input.js"
|
|
457
|
+
},
|
|
458
|
+
"amqpIntermediateOutput": {
|
|
459
|
+
"name": "amqpIntermediateOutput",
|
|
460
|
+
"types": [
|
|
461
|
+
"amqp-intermediate-output"
|
|
462
|
+
],
|
|
463
|
+
"enabled": true,
|
|
464
|
+
"local": true,
|
|
465
|
+
"user": false,
|
|
466
|
+
"module": "@5minds/node-red-contrib-processcube-amqp",
|
|
467
|
+
"file": "/data/node_modules/node-red-contrib-processcube-amqp/amqp-intermediate-output.js"
|
|
468
|
+
},
|
|
447
469
|
"amqpOutput": {
|
|
448
470
|
"name": "amqpOutput",
|
|
449
471
|
"types": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"node-red": {
|
|
3
3
|
"name": "node-red",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.3",
|
|
5
5
|
"local": false,
|
|
6
6
|
"user": false,
|
|
7
7
|
"nodes": {
|
|
@@ -429,7 +429,7 @@
|
|
|
429
429
|
},
|
|
430
430
|
"@5minds/node-red-contrib-processcube-amqp": {
|
|
431
431
|
"name": "@5minds/node-red-contrib-processcube-amqp",
|
|
432
|
-
"version": "0.
|
|
432
|
+
"version": "0.5.0",
|
|
433
433
|
"local": true,
|
|
434
434
|
"user": false,
|
|
435
435
|
"nodes": {
|
|
@@ -444,6 +444,17 @@
|
|
|
444
444
|
"module": "@5minds/node-red-contrib-processcube-amqp",
|
|
445
445
|
"file": "/data/node_modules/node-red-contrib-processcube-amqp/amqp-input.js"
|
|
446
446
|
},
|
|
447
|
+
"amqpIntermediateInput": {
|
|
448
|
+
"name": "amqpIntermediateInput",
|
|
449
|
+
"types": [
|
|
450
|
+
"amqp-intermediate-input"
|
|
451
|
+
],
|
|
452
|
+
"enabled": true,
|
|
453
|
+
"local": true,
|
|
454
|
+
"user": false,
|
|
455
|
+
"module": "@5minds/node-red-contrib-processcube-amqp",
|
|
456
|
+
"file": "/data/node_modules/node-red-contrib-processcube-amqp/amqp-intermediate-input.js"
|
|
457
|
+
},
|
|
447
458
|
"amqpOutput": {
|
|
448
459
|
"name": "amqpOutput",
|
|
449
460
|
"types": [
|
|
@@ -89,7 +89,8 @@
|
|
|
89
89
|
"amqpServer": "cbcfcb0a896f9765",
|
|
90
90
|
"exchange": "Test2",
|
|
91
91
|
"exchangeType": "topic",
|
|
92
|
-
"routingKey": "test
|
|
92
|
+
"routingKey": "test.${TEST}",
|
|
93
|
+
"routingKeyFieldType": "env",
|
|
93
94
|
"x": 630,
|
|
94
95
|
"y": 140,
|
|
95
96
|
"wires": []
|
|
@@ -116,11 +117,138 @@
|
|
|
116
117
|
"payload": "{\"test\": 1123 }",
|
|
117
118
|
"payloadType": "json",
|
|
118
119
|
"x": 250,
|
|
119
|
-
"y":
|
|
120
|
+
"y": 120,
|
|
120
121
|
"wires": [
|
|
121
122
|
[
|
|
122
123
|
"b6e1bc8cac43d73d"
|
|
123
124
|
]
|
|
124
125
|
]
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"id": "674b6dfdd29d03ff",
|
|
129
|
+
"type": "inject",
|
|
130
|
+
"z": "ea5e703747705005",
|
|
131
|
+
"name": "",
|
|
132
|
+
"props": [
|
|
133
|
+
{
|
|
134
|
+
"p": "payload"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"p": "topic",
|
|
138
|
+
"vt": "str"
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"repeat": "",
|
|
142
|
+
"crontab": "",
|
|
143
|
+
"once": false,
|
|
144
|
+
"onceDelay": 0.1,
|
|
145
|
+
"topic": "",
|
|
146
|
+
"payload": "",
|
|
147
|
+
"payloadType": "date",
|
|
148
|
+
"x": 200,
|
|
149
|
+
"y": 480,
|
|
150
|
+
"wires": [
|
|
151
|
+
[
|
|
152
|
+
"80b6a88a75218de8"
|
|
153
|
+
]
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"id": "80b6a88a75218de8",
|
|
158
|
+
"type": "amqp-intermediate-input",
|
|
159
|
+
"z": "ea5e703747705005",
|
|
160
|
+
"name": "",
|
|
161
|
+
"amqpServer": "cbcfcb0a896f9765",
|
|
162
|
+
"exchange": "Test2",
|
|
163
|
+
"exchangeType": "topic",
|
|
164
|
+
"routingKey": "test.${TEST}",
|
|
165
|
+
"routingKeyFieldType": "env",
|
|
166
|
+
"queue": "IntermediateQueue",
|
|
167
|
+
"x": 440,
|
|
168
|
+
"y": 480,
|
|
169
|
+
"wires": [
|
|
170
|
+
[
|
|
171
|
+
"3c9347a9984c8f4a"
|
|
172
|
+
]
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"id": "3c9347a9984c8f4a",
|
|
177
|
+
"type": "debug",
|
|
178
|
+
"z": "ea5e703747705005",
|
|
179
|
+
"name": "debug 3",
|
|
180
|
+
"active": true,
|
|
181
|
+
"tosidebar": true,
|
|
182
|
+
"console": false,
|
|
183
|
+
"tostatus": false,
|
|
184
|
+
"complete": "false",
|
|
185
|
+
"statusVal": "",
|
|
186
|
+
"statusType": "auto",
|
|
187
|
+
"x": 730,
|
|
188
|
+
"y": 480,
|
|
189
|
+
"wires": []
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"id": "73dfe1f014cf2a95",
|
|
193
|
+
"type": "amqp-intermediate-output",
|
|
194
|
+
"z": "ea5e703747705005",
|
|
195
|
+
"name": "",
|
|
196
|
+
"amqpServer": "cbcfcb0a896f9765",
|
|
197
|
+
"exchange": "Test2",
|
|
198
|
+
"exchangeType": "topic",
|
|
199
|
+
"routingKey": "test.${TEST}",
|
|
200
|
+
"routingKeyFieldType": "env",
|
|
201
|
+
"x": 420,
|
|
202
|
+
"y": 580,
|
|
203
|
+
"wires": [
|
|
204
|
+
[
|
|
205
|
+
"ea31e27c53c0b8cb"
|
|
206
|
+
]
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"id": "a5d8ae6eb5ac20de",
|
|
211
|
+
"type": "inject",
|
|
212
|
+
"z": "ea5e703747705005",
|
|
213
|
+
"name": "",
|
|
214
|
+
"props": [
|
|
215
|
+
{
|
|
216
|
+
"p": "payload"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"p": "topic",
|
|
220
|
+
"vt": "str"
|
|
221
|
+
}
|
|
222
|
+
],
|
|
223
|
+
"repeat": "",
|
|
224
|
+
"crontab": "",
|
|
225
|
+
"once": false,
|
|
226
|
+
"onceDelay": 0.1,
|
|
227
|
+
"topic": "",
|
|
228
|
+
"payload": "",
|
|
229
|
+
"payloadType": "date",
|
|
230
|
+
"x": 180,
|
|
231
|
+
"y": 580,
|
|
232
|
+
"wires": [
|
|
233
|
+
[
|
|
234
|
+
"73dfe1f014cf2a95"
|
|
235
|
+
]
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"id": "ea31e27c53c0b8cb",
|
|
240
|
+
"type": "debug",
|
|
241
|
+
"z": "ea5e703747705005",
|
|
242
|
+
"name": "debug 4",
|
|
243
|
+
"active": true,
|
|
244
|
+
"tosidebar": true,
|
|
245
|
+
"console": false,
|
|
246
|
+
"tostatus": false,
|
|
247
|
+
"complete": "false",
|
|
248
|
+
"statusVal": "",
|
|
249
|
+
"statusType": "auto",
|
|
250
|
+
"x": 690,
|
|
251
|
+
"y": 580,
|
|
252
|
+
"wires": []
|
|
125
253
|
}
|
|
126
254
|
]
|
|
@@ -117,11 +117,138 @@
|
|
|
117
117
|
"payload": "{\"test\": 1123 }",
|
|
118
118
|
"payloadType": "json",
|
|
119
119
|
"x": 250,
|
|
120
|
-
"y":
|
|
120
|
+
"y": 120,
|
|
121
121
|
"wires": [
|
|
122
122
|
[
|
|
123
123
|
"b6e1bc8cac43d73d"
|
|
124
124
|
]
|
|
125
125
|
]
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"id": "674b6dfdd29d03ff",
|
|
129
|
+
"type": "inject",
|
|
130
|
+
"z": "ea5e703747705005",
|
|
131
|
+
"name": "",
|
|
132
|
+
"props": [
|
|
133
|
+
{
|
|
134
|
+
"p": "payload"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"p": "topic",
|
|
138
|
+
"vt": "str"
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"repeat": "",
|
|
142
|
+
"crontab": "",
|
|
143
|
+
"once": false,
|
|
144
|
+
"onceDelay": 0.1,
|
|
145
|
+
"topic": "",
|
|
146
|
+
"payload": "",
|
|
147
|
+
"payloadType": "date",
|
|
148
|
+
"x": 200,
|
|
149
|
+
"y": 480,
|
|
150
|
+
"wires": [
|
|
151
|
+
[
|
|
152
|
+
"80b6a88a75218de8"
|
|
153
|
+
]
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"id": "80b6a88a75218de8",
|
|
158
|
+
"type": "amqp-intermediate-input",
|
|
159
|
+
"z": "ea5e703747705005",
|
|
160
|
+
"name": "",
|
|
161
|
+
"amqpServer": "cbcfcb0a896f9765",
|
|
162
|
+
"exchange": "Test2",
|
|
163
|
+
"exchangeType": "topic",
|
|
164
|
+
"routingKey": "test.${TEST}",
|
|
165
|
+
"routingKeyFieldType": "env",
|
|
166
|
+
"queue": "IntermediateQueue",
|
|
167
|
+
"x": 440,
|
|
168
|
+
"y": 480,
|
|
169
|
+
"wires": [
|
|
170
|
+
[
|
|
171
|
+
"3c9347a9984c8f4a"
|
|
172
|
+
]
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"id": "3c9347a9984c8f4a",
|
|
177
|
+
"type": "debug",
|
|
178
|
+
"z": "ea5e703747705005",
|
|
179
|
+
"name": "debug 3",
|
|
180
|
+
"active": true,
|
|
181
|
+
"tosidebar": true,
|
|
182
|
+
"console": false,
|
|
183
|
+
"tostatus": false,
|
|
184
|
+
"complete": "false",
|
|
185
|
+
"statusVal": "",
|
|
186
|
+
"statusType": "auto",
|
|
187
|
+
"x": 730,
|
|
188
|
+
"y": 480,
|
|
189
|
+
"wires": []
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"id": "73dfe1f014cf2a95",
|
|
193
|
+
"type": "amqp-intermediate-output",
|
|
194
|
+
"z": "ea5e703747705005",
|
|
195
|
+
"name": "",
|
|
196
|
+
"amqpServer": "cbcfcb0a896f9765",
|
|
197
|
+
"exchange": "Test2",
|
|
198
|
+
"exchangeType": "topic",
|
|
199
|
+
"routingKey": "test.${TEST}",
|
|
200
|
+
"routingKeyFieldType": "env",
|
|
201
|
+
"x": 420,
|
|
202
|
+
"y": 580,
|
|
203
|
+
"wires": [
|
|
204
|
+
[
|
|
205
|
+
"ea31e27c53c0b8cb"
|
|
206
|
+
]
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"id": "a5d8ae6eb5ac20de",
|
|
211
|
+
"type": "inject",
|
|
212
|
+
"z": "ea5e703747705005",
|
|
213
|
+
"name": "",
|
|
214
|
+
"props": [
|
|
215
|
+
{
|
|
216
|
+
"p": "payload"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"p": "topic",
|
|
220
|
+
"vt": "str"
|
|
221
|
+
}
|
|
222
|
+
],
|
|
223
|
+
"repeat": "",
|
|
224
|
+
"crontab": "",
|
|
225
|
+
"once": false,
|
|
226
|
+
"onceDelay": 0.1,
|
|
227
|
+
"topic": "",
|
|
228
|
+
"payload": "{\"test\":123}",
|
|
229
|
+
"payloadType": "json",
|
|
230
|
+
"x": 190,
|
|
231
|
+
"y": 580,
|
|
232
|
+
"wires": [
|
|
233
|
+
[
|
|
234
|
+
"73dfe1f014cf2a95"
|
|
235
|
+
]
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"id": "ea31e27c53c0b8cb",
|
|
240
|
+
"type": "debug",
|
|
241
|
+
"z": "ea5e703747705005",
|
|
242
|
+
"name": "debug 4",
|
|
243
|
+
"active": true,
|
|
244
|
+
"tosidebar": true,
|
|
245
|
+
"console": false,
|
|
246
|
+
"tostatus": false,
|
|
247
|
+
"complete": "false",
|
|
248
|
+
"statusVal": "",
|
|
249
|
+
"statusType": "auto",
|
|
250
|
+
"x": 690,
|
|
251
|
+
"y": 580,
|
|
252
|
+
"wires": []
|
|
126
253
|
}
|
|
127
254
|
]
|
package/amqp-config.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
const AMQPConnection = require('./amqp-connection');
|
|
2
|
+
|
|
1
3
|
module.exports = function(RED) {
|
|
2
4
|
function AMQPServerNode(n) {
|
|
3
5
|
RED.nodes.createNode(this,n);
|
|
4
6
|
this.connectionString = n.connectionString;
|
|
7
|
+
|
|
8
|
+
this.connection = new AMQPConnection(this.connectionString);
|
|
9
|
+
this.connection.connect();
|
|
5
10
|
}
|
|
6
11
|
RED.nodes.registerType("amqp-config",AMQPServerNode);
|
|
7
12
|
}
|
package/amqp-input.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const AMQPConnection = require('./amqp-connection');
|
|
2
|
-
|
|
3
1
|
function showStatus(node, msgCounter) {
|
|
4
2
|
if (msgCounter >= 1) {
|
|
5
3
|
node.status({fill: "blue", shape: "dot", text: `handling tasks ${msgCounter}`});
|
|
@@ -13,17 +11,14 @@ module.exports = function(RED) {
|
|
|
13
11
|
function AMQPInput(config) {
|
|
14
12
|
RED.nodes.createNode(this,config);
|
|
15
13
|
var node = this;
|
|
16
|
-
var flowContext = node.context().flow;
|
|
17
14
|
|
|
18
15
|
const amqpServer = RED.nodes.getNode(config.amqpServer);
|
|
19
16
|
|
|
20
17
|
async function initNode() {
|
|
21
|
-
var connection =
|
|
18
|
+
var connection = amqpServer.connection;
|
|
22
19
|
|
|
23
20
|
if (!connection) {
|
|
24
|
-
|
|
25
|
-
flowContext.set('amqpConnection', connection);
|
|
26
|
-
await connection.connect();
|
|
21
|
+
return;
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
const routingKey = (config.exchangeType == 'topic') ? RED.util.evaluateNodeProperty(config.routingKey, config.routingKeyFieldType, node) : '';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('amqp-intermediate-input',{
|
|
3
|
+
category: 'ProcessCube (MQ)',
|
|
4
|
+
color: '#00aed7',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: {value: "", type: "string"},
|
|
7
|
+
amqpServer: {value: "", type: "amqp-config"},
|
|
8
|
+
exchange: {value: "", type: "string", required:true},
|
|
9
|
+
exchangeType: { value: 'fanout'},
|
|
10
|
+
routingKey: { value: "" },
|
|
11
|
+
routingKeyFieldType: { value: "str"},
|
|
12
|
+
queue: {value: "", type: "string", required:true}
|
|
13
|
+
},
|
|
14
|
+
inputs: 1,
|
|
15
|
+
outputs: 1,
|
|
16
|
+
icon: "font-awesome/fa-envelope-open",
|
|
17
|
+
label: function() {
|
|
18
|
+
return this.name||"amqp-intermediate-input";
|
|
19
|
+
},
|
|
20
|
+
oneditprepare: function () {
|
|
21
|
+
|
|
22
|
+
$('#node-input-exchangeType').change(function (e) {
|
|
23
|
+
const exchangeType = this.value
|
|
24
|
+
|
|
25
|
+
if (['fanout'].includes(exchangeType)) {
|
|
26
|
+
$('.routing-key-form-input').hide()
|
|
27
|
+
} else {
|
|
28
|
+
$('.routing-key-form-input').show()
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
$("#node-input-routingKey").typedInput({
|
|
33
|
+
typeField: "#node-input-routingKeyFieldType",
|
|
34
|
+
types: ["str","env"]
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<script type="text/html" data-template-name="amqp-intermediate-input">
|
|
41
|
+
<div class="form-row">
|
|
42
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
43
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
44
|
+
</div>
|
|
45
|
+
<div class="form-row">
|
|
46
|
+
<label for="node-input-amqpServer"><i class="fa fa-tag"></i> AMQP Server</label>
|
|
47
|
+
<input type="text" id="node-input-amqpServer" placeholder="">
|
|
48
|
+
</div>
|
|
49
|
+
<div class="form-row wide-label-amqp-in">
|
|
50
|
+
<label for="node-input-exchangeType"><i class="fa fa-filter"></i> Type</label>
|
|
51
|
+
<select id="node-input-exchangeType">
|
|
52
|
+
<option value="topic">Topic</option>
|
|
53
|
+
<option value="direct">Direct</option>
|
|
54
|
+
<option value="fanout">Fanout</option>
|
|
55
|
+
</select>
|
|
56
|
+
</div>
|
|
57
|
+
<div class="form-row">
|
|
58
|
+
<label for="node-input-exchange"><i class="fa fa-tag"></i> Exchange</label>
|
|
59
|
+
<input type="text" id="node-input-exchange" placeholder="Exchange">
|
|
60
|
+
</div>
|
|
61
|
+
<div class="form-row routing-key-form-input">
|
|
62
|
+
<label>Routing key:</label>
|
|
63
|
+
<input type="text" id="node-input-routingKey">
|
|
64
|
+
<input type="hidden" id="node-input-routingKeyFieldType">
|
|
65
|
+
</div>
|
|
66
|
+
<div class="form-row">
|
|
67
|
+
<label for="node-input-queue"><i class="fa fa-tag"></i> Queue</label>
|
|
68
|
+
<input type="text" id="node-input-queue" placeholder="Queue">
|
|
69
|
+
</div>
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<script type="text/html" data-help-name="amqp-intermediate-input">
|
|
73
|
+
<p>A node to consume AMQP Messages.</p>
|
|
74
|
+
</script>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function showStatus(node, msgCounter) {
|
|
2
|
+
if (msgCounter >= 1) {
|
|
3
|
+
node.status({fill: "blue", shape: "dot", text: `handling tasks ${msgCounter}`});
|
|
4
|
+
} else {
|
|
5
|
+
node.status({fill: "blue", shape: "ring", text: `subcribed ${msgCounter}`});
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
module.exports = function(RED) {
|
|
10
|
+
|
|
11
|
+
function AMQPIntermediateInput(config) {
|
|
12
|
+
RED.nodes.createNode(this,config);
|
|
13
|
+
var node = this;
|
|
14
|
+
|
|
15
|
+
const amqpServer = RED.nodes.getNode(config.amqpServer);
|
|
16
|
+
|
|
17
|
+
async function initNode() {
|
|
18
|
+
var connection = amqpServer.connection;
|
|
19
|
+
|
|
20
|
+
if (!connection) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const routingKey = (config.exchangeType == 'topic') ? RED.util.evaluateNodeProperty(config.routingKey, config.routingKeyFieldType, node) : '';
|
|
25
|
+
|
|
26
|
+
const channel = await connection.createChannel();
|
|
27
|
+
await channel.assertExchange(config.exchange, config.exchangeType);
|
|
28
|
+
const queue = await channel.assertQueue(config.queue);
|
|
29
|
+
await channel.bindQueue(queue.queue, config.exchange, routingKey);
|
|
30
|
+
|
|
31
|
+
node.on('input', async function (msg) {
|
|
32
|
+
|
|
33
|
+
await channel.prefetch(1);
|
|
34
|
+
await channel.consume(queue.queue, async (message) => {
|
|
35
|
+
channel.cancel(msg._msgid);
|
|
36
|
+
msg.payload = JSON.parse(message.content.toString());
|
|
37
|
+
|
|
38
|
+
node.send(msg);
|
|
39
|
+
channel.ack(message);
|
|
40
|
+
}, { consumerTag: msg._msgid});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const onCloseHandlerId = connection.onClose(async () => {
|
|
44
|
+
console.log('onClose connection');
|
|
45
|
+
await initNode();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
node.on("close", async () => {
|
|
49
|
+
console.log('closeChannel');
|
|
50
|
+
try {
|
|
51
|
+
await channel.close();
|
|
52
|
+
connection.removeOnCloseHandler(onCloseHandlerId);
|
|
53
|
+
} catch {
|
|
54
|
+
console.warn('Channel closed');
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
initNode();
|
|
59
|
+
}
|
|
60
|
+
RED.nodes.registerType("amqp-intermediate-input", AMQPIntermediateInput);
|
|
61
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('amqp-intermediate-output',{
|
|
3
|
+
category: 'ProcessCube (MQ)',
|
|
4
|
+
color: '#00aed7',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: {value: "", type: "string"},
|
|
7
|
+
amqpServer: {value: "", type: "amqp-config"},
|
|
8
|
+
exchange: {value: "", type: "string", required:true},
|
|
9
|
+
exchangeType: { value: 'fanout'},
|
|
10
|
+
routingKey: { value: "" },
|
|
11
|
+
routingKeyFieldType: { value: "str"},
|
|
12
|
+
},
|
|
13
|
+
inputs: 1,
|
|
14
|
+
outputs: 1,
|
|
15
|
+
icon: "font-awesome/fa-envelope-open",
|
|
16
|
+
label: function() {
|
|
17
|
+
return this.name||"amqp-intermediate-output";
|
|
18
|
+
},
|
|
19
|
+
oneditprepare: function () {
|
|
20
|
+
|
|
21
|
+
$('#node-input-exchangeType').change(function (e) {
|
|
22
|
+
const exchangeType = this.value
|
|
23
|
+
|
|
24
|
+
if (['fanout'].includes(exchangeType)) {
|
|
25
|
+
$('.routing-key-form-input').hide()
|
|
26
|
+
} else {
|
|
27
|
+
$('.routing-key-form-input').show()
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
$("#node-input-routingKey").typedInput({
|
|
32
|
+
typeField: "#node-input-routingKeyFieldType",
|
|
33
|
+
types: ["str","env"]
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<script type="text/html" data-template-name="amqp-intermediate-output">
|
|
40
|
+
<div class="form-row">
|
|
41
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
42
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
43
|
+
</div>
|
|
44
|
+
<div class="form-row">
|
|
45
|
+
<label for="node-input-amqpServer"><i class="fa fa-tag"></i> AMQP Server</label>
|
|
46
|
+
<input type="text" id="node-input-amqpServer" placeholder="">
|
|
47
|
+
</div>
|
|
48
|
+
<div class="form-row wide-label-amqp-in">
|
|
49
|
+
<label for="node-input-exchangeType"><i class="fa fa-filter"></i> Type</label>
|
|
50
|
+
<select id="node-input-exchangeType">
|
|
51
|
+
<option value="topic">Topic</option>
|
|
52
|
+
<option value="direct">Direct</option>
|
|
53
|
+
<option value="fanout">Fanout</option>
|
|
54
|
+
</select>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="form-row">
|
|
57
|
+
<label for="node-input-exchange"><i class="fa fa-tag"></i> Exchange</label>
|
|
58
|
+
<input type="text" id="node-input-exchange" placeholder="Exchange">
|
|
59
|
+
</div>
|
|
60
|
+
<div class="form-row routing-key-form-input">
|
|
61
|
+
<label>Routing key:</label>
|
|
62
|
+
<input type="text" id="node-input-routingKey">
|
|
63
|
+
<input type="hidden" id="node-input-routingKeyFieldType">
|
|
64
|
+
</div>
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<script type="text/html" data-help-name="amqp-intermediate-output">
|
|
68
|
+
<p>A node to publish AMQP Messages.</p>
|
|
69
|
+
</script>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module.exports = function(RED) {
|
|
2
|
+
function AMQPIntermediateOutput(config) {
|
|
3
|
+
RED.nodes.createNode(this,config);
|
|
4
|
+
var node = this;
|
|
5
|
+
var flowContext = node.context().flow;
|
|
6
|
+
|
|
7
|
+
const amqpServer = RED.nodes.getNode(config.amqpServer);
|
|
8
|
+
|
|
9
|
+
node.on('input', async (msg) => {
|
|
10
|
+
var connection = amqpServer.connection;
|
|
11
|
+
|
|
12
|
+
if (!connection) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const routingKey = (config.exchangeType == 'topic') ? RED.util.evaluateNodeProperty(config.routingKey, config.routingKeyFieldType, node) : '';
|
|
17
|
+
|
|
18
|
+
const channel = await connection.createChannel();
|
|
19
|
+
await channel.assertExchange(config.exchange, config.exchangeType);
|
|
20
|
+
|
|
21
|
+
await channel.publish(config.exchange, routingKey, Buffer.from(JSON.stringify(msg.payload)));
|
|
22
|
+
await channel.close();
|
|
23
|
+
|
|
24
|
+
node.send(msg);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
RED.nodes.registerType("amqp-intermediate-output", AMQPIntermediateOutput);
|
|
29
|
+
}
|
package/amqp-output.js
CHANGED
|
@@ -10,11 +10,10 @@ module.exports = function(RED) {
|
|
|
10
10
|
const amqpServer = RED.nodes.getNode(config.amqpServer);
|
|
11
11
|
|
|
12
12
|
node.on('input', async (msg) => {
|
|
13
|
-
var connection =
|
|
13
|
+
var connection = amqpServer.connection;
|
|
14
14
|
|
|
15
15
|
if (!connection) {
|
|
16
|
-
|
|
17
|
-
flowContext.set('amqpConnection', connection);
|
|
16
|
+
return;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
const routingKey = (config.exchangeType == 'topic') ? RED.util.evaluateNodeProperty(config.routingKey, config.routingKeyFieldType, node) : '';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@5minds/node-red-contrib-processcube-amqp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Node-RED nodes for AMQP",
|
|
6
6
|
"authors": [
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
"version": ">=3.1.9",
|
|
30
30
|
"nodes": {
|
|
31
31
|
"amqpInput": "amqp-input.js",
|
|
32
|
+
"amqpIntermediateInput": "amqp-intermediate-input.js",
|
|
33
|
+
"amqpIntermediateOutput": "amqp-intermediate-output.js",
|
|
32
34
|
"amqpOutput": "amqp-output.js",
|
|
33
35
|
"amqpConfig": "amqp-config.js"
|
|
34
36
|
}
|