@5minds/node-red-contrib-processcube-amqp 0.4.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "node-red": {
3
3
  "name": "node-red",
4
- "version": "3.1.9",
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.2.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": "3.1.9",
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.1.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": [
@@ -13,7 +13,7 @@
13
13
  "view-show-welcome-tours": true
14
14
  },
15
15
  "tours": {
16
- "welcome": "3.1.9"
16
+ "welcome": "4.0.3"
17
17
  }
18
18
  }
19
19
  }
@@ -11,6 +11,9 @@
11
11
  "view-node-show-label": true,
12
12
  "view-show-tips": true,
13
13
  "view-show-welcome-tours": true
14
+ },
15
+ "tours": {
16
+ "welcome": "3.1.9"
14
17
  }
15
18
  }
16
19
  }
@@ -23,7 +23,7 @@
23
23
  "routingKey": "",
24
24
  "queue": "Test",
25
25
  "x": 210,
26
- "y": 260,
26
+ "y": 240,
27
27
  "wires": [
28
28
  [
29
29
  "ad189622d10f3966"
@@ -52,9 +52,10 @@
52
52
  "z": "ea5e703747705005",
53
53
  "name": "",
54
54
  "amqpServer": "cbcfcb0a896f9765",
55
- "exchange": "Test2__",
55
+ "exchange": "Test2",
56
56
  "exchangeType": "topic",
57
- "routingKey": "test.*",
57
+ "routingKey": "test.${TEST}",
58
+ "routingKeyFieldType": "env",
58
59
  "queue": "Test2",
59
60
  "x": 210,
60
61
  "y": 380,
@@ -88,7 +89,8 @@
88
89
  "amqpServer": "cbcfcb0a896f9765",
89
90
  "exchange": "Test2",
90
91
  "exchangeType": "topic",
91
- "routingKey": "test.test",
92
+ "routingKey": "test.${TEST}",
93
+ "routingKeyFieldType": "env",
92
94
  "x": 630,
93
95
  "y": 140,
94
96
  "wires": []
@@ -115,11 +117,138 @@
115
117
  "payload": "{\"test\": 1123 }",
116
118
  "payloadType": "json",
117
119
  "x": 250,
118
- "y": 140,
120
+ "y": 120,
119
121
  "wires": [
120
122
  [
121
123
  "b6e1bc8cac43d73d"
122
124
  ]
123
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": []
124
253
  }
125
254
  ]
@@ -23,7 +23,7 @@
23
23
  "routingKey": "",
24
24
  "queue": "Test",
25
25
  "x": 210,
26
- "y": 260,
26
+ "y": 240,
27
27
  "wires": [
28
28
  [
29
29
  "ad189622d10f3966"
@@ -54,7 +54,8 @@
54
54
  "amqpServer": "cbcfcb0a896f9765",
55
55
  "exchange": "Test2",
56
56
  "exchangeType": "topic",
57
- "routingKey": "test.*",
57
+ "routingKey": "test.${TEST}",
58
+ "routingKeyFieldType": "env",
58
59
  "queue": "Test2",
59
60
  "x": 210,
60
61
  "y": 380,
@@ -88,7 +89,8 @@
88
89
  "amqpServer": "cbcfcb0a896f9765",
89
90
  "exchange": "Test2",
90
91
  "exchangeType": "topic",
91
- "routingKey": "test.test",
92
+ "routingKey": "test.${TEST}",
93
+ "routingKeyFieldType": "env",
92
94
  "x": 630,
93
95
  "y": 140,
94
96
  "wires": []
@@ -115,11 +117,138 @@
115
117
  "payload": "{\"test\": 1123 }",
116
118
  "payloadType": "json",
117
119
  "x": 250,
118
- "y": 140,
120
+ "y": 120,
119
121
  "wires": [
120
122
  [
121
123
  "b6e1bc8cac43d73d"
122
124
  ]
123
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": []
124
253
  }
125
254
  ]
@@ -481,6 +481,7 @@ module.exports = {
481
481
  */
482
482
  functionGlobalContext: {
483
483
  // os:require('os'),
484
+ env: process.env
484
485
  },
485
486
 
486
487
  /** The maximum number of messages nodes will buffer internally as part of their
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.html CHANGED
@@ -8,6 +8,7 @@
8
8
  exchange: {value: "", type: "string", required:true},
9
9
  exchangeType: { value: 'fanout'},
10
10
  routingKey: { value: "" },
11
+ routingKeyFieldType: { value: "str"},
11
12
  queue: {value: "", type: "string", required:true}
12
13
  },
13
14
  inputs: 0,
@@ -27,6 +28,11 @@
27
28
  $('.routing-key-form-input').show()
28
29
  }
29
30
  })
31
+
32
+ $("#node-input-routingKey").typedInput({
33
+ typeField: "#node-input-routingKeyFieldType",
34
+ types: ["str","env"]
35
+ });
30
36
  },
31
37
  });
32
38
  </script>
@@ -52,9 +58,10 @@
52
58
  <label for="node-input-exchange"><i class="fa fa-tag"></i> Exchange</label>
53
59
  <input type="text" id="node-input-exchange" placeholder="Exchange">
54
60
  </div>
55
- <div class="form-row wide-label-amqp-in routing-key-form-input">
56
- <label for="node-input-routingKey"><i class="fa fa-filter"></i>&nbsp;&nbsp;Routing Key</label>
61
+ <div class="form-row routing-key-form-input">
62
+ <label>Routing key:</label>
57
63
  <input type="text" id="node-input-routingKey">
64
+ <input type="hidden" id="node-input-routingKeyFieldType">
58
65
  </div>
59
66
  <div class="form-row">
60
67
  <label for="node-input-queue"><i class="fa fa-tag"></i> Queue</label>
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,23 +11,22 @@ 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 = flowContext.get('amqpConnection');
18
+ var connection = amqpServer.connection;
22
19
 
23
20
  if (!connection) {
24
- connection = new AMQPConnection(amqpServer.connectionString);
25
- flowContext.set('amqpConnection', connection);
26
- await connection.connect();
21
+ return;
27
22
  }
23
+
24
+ const routingKey = (config.exchangeType == 'topic') ? RED.util.evaluateNodeProperty(config.routingKey, config.routingKeyFieldType, node) : '';
28
25
 
29
26
  const channel = await connection.createChannel();
30
27
  await channel.assertExchange(config.exchange, config.exchangeType);
31
28
  const queue = await channel.assertQueue(config.queue);
32
- await channel.bindQueue(queue.queue, config.exchange, config.routingKey);
29
+ await channel.bindQueue(queue.queue, config.exchange, routingKey);
33
30
 
34
31
  await channel.consume(queue.queue, async (message) => {
35
32
  const msg = {
@@ -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>&nbsp;&nbsp;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>&nbsp;&nbsp;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.html CHANGED
@@ -8,6 +8,7 @@
8
8
  exchange: {value: "", type: "string", required:true},
9
9
  exchangeType: { value: 'fanout'},
10
10
  routingKey: { value: "" },
11
+ routingKeyFieldType: { value: "str"},
11
12
  },
12
13
  inputs: 1,
13
14
  outputs: 0,
@@ -25,7 +26,12 @@
25
26
  } else {
26
27
  $('.routing-key-form-input').show()
27
28
  }
28
- })
29
+ });
30
+
31
+ $("#node-input-routingKey").typedInput({
32
+ typeField: "#node-input-routingKeyFieldType",
33
+ types: ["str","env"]
34
+ });
29
35
  },
30
36
  });
31
37
  </script>
@@ -51,9 +57,10 @@
51
57
  <label for="node-input-exchange"><i class="fa fa-tag"></i> Exchange</label>
52
58
  <input type="text" id="node-input-exchange" placeholder="Exchange">
53
59
  </div>
54
- <div class="form-row wide-label-amqp-in routing-key-form-input">
55
- <label for="node-input-routingKey"><i class="fa fa-filter"></i>&nbsp;&nbsp;Routing Key</label>
60
+ <div class="form-row routing-key-form-input">
61
+ <label>Routing key:</label>
56
62
  <input type="text" id="node-input-routingKey">
63
+ <input type="hidden" id="node-input-routingKeyFieldType">
57
64
  </div>
58
65
  </script>
59
66
 
package/amqp-output.js CHANGED
@@ -10,17 +10,18 @@ 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 = flowContext.get('amqpConnection');
13
+ var connection = amqpServer.connection;
14
14
 
15
15
  if (!connection) {
16
- connection = new AMQPConnection(amqpServer.connectionString);
17
- flowContext.set('amqpConnection', connection);
16
+ return;
18
17
  }
18
+
19
+ const routingKey = (config.exchangeType == 'topic') ? RED.util.evaluateNodeProperty(config.routingKey, config.routingKeyFieldType, node) : '';
19
20
 
20
21
  const channel = await connection.createChannel();
21
22
  await channel.assertExchange(config.exchange, config.exchangeType);
22
23
 
23
- await channel.publish(config.exchange, config.routingKey, Buffer.from(JSON.stringify(msg.payload)));
24
+ await channel.publish(config.exchange, routingKey, Buffer.from(JSON.stringify(msg.payload)));
24
25
  await channel.close();
25
26
  });
26
27
 
@@ -5,6 +5,7 @@ services:
5
5
  context: .
6
6
  environment:
7
7
  - TZ=Europe/Berlin
8
+ - TEST=hallo
8
9
  ports:
9
10
  - "1880:1880"
10
11
  volumes:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube-amqp",
3
- "version": "0.4.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
  }