node-red-contrib-qrusty 0.19.20 → 0.20.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/README.md +133 -26
- package/lib/common.js +94 -0
- package/package.json +37 -7
- package/qrusty-ack-batch.html +68 -0
- package/qrusty-ack-batch.js +37 -9
- package/qrusty-ack.html +66 -0
- package/qrusty-ack.js +32 -11
- package/qrusty-consume.html +76 -0
- package/qrusty-consume.js +37 -8
- package/qrusty-create-queue.html +82 -0
- package/qrusty-create-queue.js +39 -13
- package/qrusty-delete-all.html +38 -0
- package/qrusty-delete-all.js +19 -5
- package/qrusty-delete-queue.html +51 -0
- package/qrusty-delete-queue.js +21 -5
- package/qrusty-health.html +37 -0
- package/qrusty-health.js +19 -5
- package/qrusty-list-queues.html +37 -0
- package/qrusty-list-queues.js +19 -5
- package/qrusty-nack-batch.html +67 -0
- package/qrusty-nack-batch.js +37 -9
- package/qrusty-nack.html +66 -0
- package/qrusty-nack.js +31 -11
- package/qrusty-publish.html +92 -0
- package/qrusty-publish.js +37 -10
- package/qrusty-purge-all.html +41 -0
- package/qrusty-purge-all.js +19 -5
- package/qrusty-purge-queue.html +51 -0
- package/qrusty-purge-queue.js +21 -5
- package/qrusty-queue-metrics.html +51 -0
- package/qrusty-queue-metrics.js +21 -6
- package/qrusty-queue-stats.html +51 -0
- package/qrusty-queue-stats.js +21 -5
- package/qrusty-server.html +64 -0
- package/qrusty-server.js +20 -0
- package/qrusty-stats.html +37 -0
- package/qrusty-stats.js +19 -5
- package/qrusty-update-queue.html +77 -0
- package/qrusty-update-queue.js +37 -12
package/qrusty-consume.js
CHANGED
|
@@ -1,9 +1,38 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
msg.payload
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// qrusty-consume.js
|
|
2
|
+
//
|
|
3
|
+
// Pops (consumes) one message from a Qrusty queue. The returned message
|
|
4
|
+
// is placed in msg.payload, or null if the queue is empty.
|
|
5
|
+
//
|
|
6
|
+
// This is a request/response-style node: trigger it with any input msg
|
|
7
|
+
// and it performs exactly one consume call, returning immediately.
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
setupActionNode,
|
|
11
|
+
fromConfigOrMsg,
|
|
12
|
+
toNumberOrUndefined,
|
|
13
|
+
} = require("./lib/common");
|
|
14
|
+
|
|
15
|
+
module.exports = function (RED) {
|
|
16
|
+
function QrustyConsumeNode(n) {
|
|
17
|
+
RED.nodes.createNode(this, n);
|
|
18
|
+
const node = this;
|
|
19
|
+
const server = RED.nodes.getNode(n.server);
|
|
20
|
+
|
|
21
|
+
setupActionNode(node, server, async (client, msg) => {
|
|
22
|
+
const queue = fromConfigOrMsg(n.queue, msg.queue);
|
|
23
|
+
if (!queue) {
|
|
24
|
+
throw new Error("queue is required (set on the node or via msg.queue)");
|
|
25
|
+
}
|
|
26
|
+
const consumerId =
|
|
27
|
+
fromConfigOrMsg(n.consumerId, msg.consumer_id) || "node-red-consumer";
|
|
28
|
+
const timeoutSeconds =
|
|
29
|
+
toNumberOrUndefined(
|
|
30
|
+
fromConfigOrMsg(n.timeoutSeconds, msg.timeout_seconds),
|
|
31
|
+
) ?? 30;
|
|
32
|
+
|
|
33
|
+
return await client.consume(queue, consumerId, timeoutSeconds);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
RED.nodes.registerType("qrusty-consume", QrustyConsumeNode);
|
|
7
38
|
};
|
|
8
|
-
msg.headers = { "Content-Type": "application/json" };
|
|
9
|
-
return msg;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType("qrusty-create-queue", {
|
|
3
|
+
category: "qrusty",
|
|
4
|
+
color: "#9acfe6",
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
server: { value: "", type: "qrusty-server", required: true },
|
|
8
|
+
queue: { value: "" },
|
|
9
|
+
ordering: { value: "MaxFirst" },
|
|
10
|
+
priorityKind: { value: "Numeric" },
|
|
11
|
+
allowDuplicates: { value: "true" },
|
|
12
|
+
},
|
|
13
|
+
inputs: 1,
|
|
14
|
+
outputs: 1,
|
|
15
|
+
icon: "font-awesome/fa-plus-square",
|
|
16
|
+
label: function () {
|
|
17
|
+
return this.name || "qrusty create-queue";
|
|
18
|
+
},
|
|
19
|
+
paletteLabel: "create-queue",
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<script type="text/html" data-template-name="qrusty-create-queue">
|
|
24
|
+
<div class="form-row">
|
|
25
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
26
|
+
<input type="text" id="node-input-name" placeholder="optional" />
|
|
27
|
+
</div>
|
|
28
|
+
<div class="form-row">
|
|
29
|
+
<label for="node-input-server"><i class="fa fa-server"></i> Server</label>
|
|
30
|
+
<input type="text" id="node-input-server" />
|
|
31
|
+
</div>
|
|
32
|
+
<div class="form-row">
|
|
33
|
+
<label for="node-input-queue"><i class="fa fa-list"></i> Queue</label>
|
|
34
|
+
<input
|
|
35
|
+
type="text"
|
|
36
|
+
id="node-input-queue"
|
|
37
|
+
placeholder="leave blank to use msg.queue"
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
<div class="form-row">
|
|
41
|
+
<label for="node-input-ordering"
|
|
42
|
+
><i class="fa fa-sort"></i> Ordering</label
|
|
43
|
+
>
|
|
44
|
+
<select id="node-input-ordering">
|
|
45
|
+
<option value="MaxFirst">MaxFirst</option>
|
|
46
|
+
<option value="MinFirst">MinFirst</option>
|
|
47
|
+
<option value="Fifo">Fifo</option>
|
|
48
|
+
</select>
|
|
49
|
+
</div>
|
|
50
|
+
<div class="form-row">
|
|
51
|
+
<label for="node-input-priorityKind"
|
|
52
|
+
><i class="fa fa-list-ol"></i> Priority kind</label
|
|
53
|
+
>
|
|
54
|
+
<select id="node-input-priorityKind">
|
|
55
|
+
<option value="Numeric">Numeric</option>
|
|
56
|
+
<option value="Text">Text</option>
|
|
57
|
+
</select>
|
|
58
|
+
</div>
|
|
59
|
+
<div class="form-row">
|
|
60
|
+
<label for="node-input-allowDuplicates"
|
|
61
|
+
><i class="fa fa-clone"></i> Duplicates</label
|
|
62
|
+
>
|
|
63
|
+
<select id="node-input-allowDuplicates">
|
|
64
|
+
<option value="true">Allowed</option>
|
|
65
|
+
<option value="false">Blocked</option>
|
|
66
|
+
</select>
|
|
67
|
+
</div>
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<script type="text/html" data-help-name="qrusty-create-queue">
|
|
71
|
+
<p>Creates a new Qrusty queue. Throws if the queue already exists.</p>
|
|
72
|
+
<h3>Inputs</h3>
|
|
73
|
+
<dl class="message-properties">
|
|
74
|
+
<dt class="optional">queue <span class="property-type">string</span></dt>
|
|
75
|
+
<dd>Name for the new queue (when the Queue field is blank).</dd>
|
|
76
|
+
</dl>
|
|
77
|
+
<h3>Outputs</h3>
|
|
78
|
+
<dl class="message-properties">
|
|
79
|
+
<dt>payload <span class="property-type">object</span></dt>
|
|
80
|
+
<dd><code>{ ok: true, name: "<queue>" }</code> on success.</dd>
|
|
81
|
+
</dl>
|
|
82
|
+
</script>
|
package/qrusty-create-queue.js
CHANGED
|
@@ -1,14 +1,40 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
// qrusty-create-queue.js
|
|
2
|
+
//
|
|
3
|
+
// Creates a new queue on the Qrusty server.
|
|
4
|
+
|
|
5
|
+
const { setupActionNode, fromConfigOrMsg } = require("./lib/common");
|
|
6
|
+
|
|
7
|
+
module.exports = function (RED) {
|
|
8
|
+
function QrustyCreateQueueNode(n) {
|
|
9
|
+
RED.nodes.createNode(this, n);
|
|
10
|
+
const node = this;
|
|
11
|
+
const server = RED.nodes.getNode(n.server);
|
|
12
|
+
|
|
13
|
+
setupActionNode(node, server, async (client, msg) => {
|
|
14
|
+
const queue = fromConfigOrMsg(n.queue, msg.queue);
|
|
15
|
+
if (!queue) throw new Error("queue name is required");
|
|
16
|
+
|
|
17
|
+
const ordering = fromConfigOrMsg(n.ordering, msg.ordering) || "MaxFirst";
|
|
18
|
+
const priorityKind =
|
|
19
|
+
fromConfigOrMsg(n.priorityKind, msg.priority_kind) || "Numeric";
|
|
20
|
+
|
|
21
|
+
// allowDuplicates is a boolean; treat config "true"/"false" strings
|
|
22
|
+
// as their boolean equivalents. Default is true.
|
|
23
|
+
let allowDuplicates;
|
|
24
|
+
if (n.allowDuplicates === "false" || n.allowDuplicates === false) {
|
|
25
|
+
allowDuplicates = false;
|
|
26
|
+
} else if (n.allowDuplicates === "true" || n.allowDuplicates === true) {
|
|
27
|
+
allowDuplicates = true;
|
|
28
|
+
} else if (typeof msg.allow_duplicates === "boolean") {
|
|
29
|
+
allowDuplicates = msg.allow_duplicates;
|
|
30
|
+
} else {
|
|
31
|
+
allowDuplicates = true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
await client.createQueue(queue, ordering, allowDuplicates, priorityKind);
|
|
35
|
+
return { ok: true, name: queue };
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
RED.nodes.registerType("qrusty-create-queue", QrustyCreateQueueNode);
|
|
12
40
|
};
|
|
13
|
-
msg.headers = { "Content-Type": "application/json" };
|
|
14
|
-
return msg;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType("qrusty-delete-all", {
|
|
3
|
+
category: "qrusty",
|
|
4
|
+
color: "#e99999",
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
server: { value: "", type: "qrusty-server", required: true },
|
|
8
|
+
},
|
|
9
|
+
inputs: 1,
|
|
10
|
+
outputs: 1,
|
|
11
|
+
icon: "font-awesome/fa-trash-o",
|
|
12
|
+
label: function () {
|
|
13
|
+
return this.name || "qrusty delete-all";
|
|
14
|
+
},
|
|
15
|
+
paletteLabel: "delete-all",
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script type="text/html" data-template-name="qrusty-delete-all">
|
|
20
|
+
<div class="form-row">
|
|
21
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
22
|
+
<input type="text" id="node-input-name" placeholder="optional" />
|
|
23
|
+
</div>
|
|
24
|
+
<div class="form-row">
|
|
25
|
+
<label for="node-input-server"><i class="fa fa-server"></i> Server</label>
|
|
26
|
+
<input type="text" id="node-input-server" />
|
|
27
|
+
</div>
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<script type="text/html" data-help-name="qrusty-delete-all">
|
|
31
|
+
<p>Deletes every queue on the server and all of their messages.</p>
|
|
32
|
+
<p><b>Warning:</b> this is irreversible.</p>
|
|
33
|
+
<h3>Outputs</h3>
|
|
34
|
+
<dl class="message-properties">
|
|
35
|
+
<dt>payload <span class="property-type">object</span></dt>
|
|
36
|
+
<dd>Server response.</dd>
|
|
37
|
+
</dl>
|
|
38
|
+
</script>
|
package/qrusty-delete-all.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// qrusty-delete-all.js
|
|
2
|
+
//
|
|
3
|
+
// Deletes every queue on the server (and all their messages).
|
|
4
|
+
|
|
5
|
+
const { setupActionNode } = require("./lib/common");
|
|
6
|
+
|
|
7
|
+
module.exports = function (RED) {
|
|
8
|
+
function QrustyDeleteAllNode(n) {
|
|
9
|
+
RED.nodes.createNode(this, n);
|
|
10
|
+
const node = this;
|
|
11
|
+
const server = RED.nodes.getNode(n.server);
|
|
12
|
+
|
|
13
|
+
setupActionNode(node, server, async (client /*, msg */) => {
|
|
14
|
+
return await client.deleteAll();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
RED.nodes.registerType("qrusty-delete-all", QrustyDeleteAllNode);
|
|
19
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType("qrusty-delete-queue", {
|
|
3
|
+
category: "qrusty",
|
|
4
|
+
color: "#e99999",
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
server: { value: "", type: "qrusty-server", required: true },
|
|
8
|
+
queue: { value: "" },
|
|
9
|
+
},
|
|
10
|
+
inputs: 1,
|
|
11
|
+
outputs: 1,
|
|
12
|
+
icon: "font-awesome/fa-trash",
|
|
13
|
+
label: function () {
|
|
14
|
+
return this.name || "qrusty delete-queue";
|
|
15
|
+
},
|
|
16
|
+
paletteLabel: "delete-queue",
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script type="text/html" data-template-name="qrusty-delete-queue">
|
|
21
|
+
<div class="form-row">
|
|
22
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
23
|
+
<input type="text" id="node-input-name" placeholder="optional" />
|
|
24
|
+
</div>
|
|
25
|
+
<div class="form-row">
|
|
26
|
+
<label for="node-input-server"><i class="fa fa-server"></i> Server</label>
|
|
27
|
+
<input type="text" id="node-input-server" />
|
|
28
|
+
</div>
|
|
29
|
+
<div class="form-row">
|
|
30
|
+
<label for="node-input-queue"><i class="fa fa-list"></i> Queue</label>
|
|
31
|
+
<input
|
|
32
|
+
type="text"
|
|
33
|
+
id="node-input-queue"
|
|
34
|
+
placeholder="leave blank to use msg.queue"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<script type="text/html" data-help-name="qrusty-delete-queue">
|
|
40
|
+
<p>Deletes a Qrusty queue and all of its messages.</p>
|
|
41
|
+
<h3>Inputs</h3>
|
|
42
|
+
<dl class="message-properties">
|
|
43
|
+
<dt class="optional">queue <span class="property-type">string</span></dt>
|
|
44
|
+
<dd>Queue to delete (when the Queue field is blank).</dd>
|
|
45
|
+
</dl>
|
|
46
|
+
<h3>Outputs</h3>
|
|
47
|
+
<dl class="message-properties">
|
|
48
|
+
<dt>payload <span class="property-type">object</span></dt>
|
|
49
|
+
<dd>Server response.</dd>
|
|
50
|
+
</dl>
|
|
51
|
+
</script>
|
package/qrusty-delete-queue.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// qrusty-delete-queue.js
|
|
2
|
+
//
|
|
3
|
+
// Deletes a queue and all of its messages.
|
|
4
|
+
|
|
5
|
+
const { setupActionNode, fromConfigOrMsg } = require("./lib/common");
|
|
6
|
+
|
|
7
|
+
module.exports = function (RED) {
|
|
8
|
+
function QrustyDeleteQueueNode(n) {
|
|
9
|
+
RED.nodes.createNode(this, n);
|
|
10
|
+
const node = this;
|
|
11
|
+
const server = RED.nodes.getNode(n.server);
|
|
12
|
+
|
|
13
|
+
setupActionNode(node, server, async (client, msg) => {
|
|
14
|
+
const queue = fromConfigOrMsg(n.queue, msg.queue);
|
|
15
|
+
if (!queue) throw new Error("queue name is required");
|
|
16
|
+
return await client.deleteQueue(queue);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
RED.nodes.registerType("qrusty-delete-queue", QrustyDeleteQueueNode);
|
|
21
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType("qrusty-health", {
|
|
3
|
+
category: "qrusty",
|
|
4
|
+
color: "#b9d18c",
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
server: { value: "", type: "qrusty-server", required: true },
|
|
8
|
+
},
|
|
9
|
+
inputs: 1,
|
|
10
|
+
outputs: 1,
|
|
11
|
+
icon: "font-awesome/fa-heartbeat",
|
|
12
|
+
label: function () {
|
|
13
|
+
return this.name || "qrusty health";
|
|
14
|
+
},
|
|
15
|
+
paletteLabel: "health",
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script type="text/html" data-template-name="qrusty-health">
|
|
20
|
+
<div class="form-row">
|
|
21
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
22
|
+
<input type="text" id="node-input-name" placeholder="optional" />
|
|
23
|
+
</div>
|
|
24
|
+
<div class="form-row">
|
|
25
|
+
<label for="node-input-server"><i class="fa fa-server"></i> Server</label>
|
|
26
|
+
<input type="text" id="node-input-server" />
|
|
27
|
+
</div>
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<script type="text/html" data-help-name="qrusty-health">
|
|
31
|
+
<p>Checks the Qrusty server's <code>/health</code> endpoint.</p>
|
|
32
|
+
<h3>Outputs</h3>
|
|
33
|
+
<dl class="message-properties">
|
|
34
|
+
<dt>payload <span class="property-type">object</span></dt>
|
|
35
|
+
<dd>The health payload, usually <code>{ status: "ok" }</code>.</dd>
|
|
36
|
+
</dl>
|
|
37
|
+
</script>
|
package/qrusty-health.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// qrusty-health.js
|
|
2
|
+
//
|
|
3
|
+
// Checks the Qrusty server's /health endpoint.
|
|
4
|
+
|
|
5
|
+
const { setupActionNode } = require("./lib/common");
|
|
6
|
+
|
|
7
|
+
module.exports = function (RED) {
|
|
8
|
+
function QrustyHealthNode(n) {
|
|
9
|
+
RED.nodes.createNode(this, n);
|
|
10
|
+
const node = this;
|
|
11
|
+
const server = RED.nodes.getNode(n.server);
|
|
12
|
+
|
|
13
|
+
setupActionNode(node, server, async (client /*, msg */) => {
|
|
14
|
+
return await client.health();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
RED.nodes.registerType("qrusty-health", QrustyHealthNode);
|
|
19
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType("qrusty-list-queues", {
|
|
3
|
+
category: "qrusty",
|
|
4
|
+
color: "#b9d18c",
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
server: { value: "", type: "qrusty-server", required: true },
|
|
8
|
+
},
|
|
9
|
+
inputs: 1,
|
|
10
|
+
outputs: 1,
|
|
11
|
+
icon: "font-awesome/fa-list-alt",
|
|
12
|
+
label: function () {
|
|
13
|
+
return this.name || "qrusty list-queues";
|
|
14
|
+
},
|
|
15
|
+
paletteLabel: "list-queues",
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script type="text/html" data-template-name="qrusty-list-queues">
|
|
20
|
+
<div class="form-row">
|
|
21
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
22
|
+
<input type="text" id="node-input-name" placeholder="optional" />
|
|
23
|
+
</div>
|
|
24
|
+
<div class="form-row">
|
|
25
|
+
<label for="node-input-server"><i class="fa fa-server"></i> Server</label>
|
|
26
|
+
<input type="text" id="node-input-server" />
|
|
27
|
+
</div>
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<script type="text/html" data-help-name="qrusty-list-queues">
|
|
31
|
+
<p>Returns the list of queues that exist on the server.</p>
|
|
32
|
+
<h3>Outputs</h3>
|
|
33
|
+
<dl class="message-properties">
|
|
34
|
+
<dt>payload <span class="property-type">string[]</span></dt>
|
|
35
|
+
<dd>Array of queue names.</dd>
|
|
36
|
+
</dl>
|
|
37
|
+
</script>
|
package/qrusty-list-queues.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// qrusty-list-queues.js
|
|
2
|
+
//
|
|
3
|
+
// Lists every queue on the server.
|
|
4
|
+
|
|
5
|
+
const { setupActionNode } = require("./lib/common");
|
|
6
|
+
|
|
7
|
+
module.exports = function (RED) {
|
|
8
|
+
function QrustyListQueuesNode(n) {
|
|
9
|
+
RED.nodes.createNode(this, n);
|
|
10
|
+
const node = this;
|
|
11
|
+
const server = RED.nodes.getNode(n.server);
|
|
12
|
+
|
|
13
|
+
setupActionNode(node, server, async (client /*, msg */) => {
|
|
14
|
+
return await client.listQueues();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
RED.nodes.registerType("qrusty-list-queues", QrustyListQueuesNode);
|
|
19
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType("qrusty-nack-batch", {
|
|
3
|
+
category: "qrusty",
|
|
4
|
+
color: "#d78a4e",
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
server: { value: "", type: "qrusty-server", required: true },
|
|
8
|
+
queue: { value: "" },
|
|
9
|
+
consumerId: { value: "" },
|
|
10
|
+
},
|
|
11
|
+
inputs: 1,
|
|
12
|
+
outputs: 1,
|
|
13
|
+
icon: "font-awesome/fa-times-circle",
|
|
14
|
+
label: function () {
|
|
15
|
+
return this.name || "qrusty nack batch";
|
|
16
|
+
},
|
|
17
|
+
paletteLabel: "nack batch",
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script type="text/html" data-template-name="qrusty-nack-batch">
|
|
22
|
+
<div class="form-row">
|
|
23
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
24
|
+
<input type="text" id="node-input-name" placeholder="optional" />
|
|
25
|
+
</div>
|
|
26
|
+
<div class="form-row">
|
|
27
|
+
<label for="node-input-server"><i class="fa fa-server"></i> Server</label>
|
|
28
|
+
<input type="text" id="node-input-server" />
|
|
29
|
+
</div>
|
|
30
|
+
<div class="form-row">
|
|
31
|
+
<label for="node-input-queue"><i class="fa fa-list"></i> Queue</label>
|
|
32
|
+
<input
|
|
33
|
+
type="text"
|
|
34
|
+
id="node-input-queue"
|
|
35
|
+
placeholder="leave blank to use msg.queue"
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="form-row">
|
|
39
|
+
<label for="node-input-consumerId"
|
|
40
|
+
><i class="fa fa-user"></i> Consumer ID</label
|
|
41
|
+
>
|
|
42
|
+
<input
|
|
43
|
+
type="text"
|
|
44
|
+
id="node-input-consumerId"
|
|
45
|
+
placeholder="default node-red-consumer"
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<script type="text/html" data-help-name="qrusty-nack-batch">
|
|
51
|
+
<p>Negatively acknowledges multiple messages at once.</p>
|
|
52
|
+
<h3>Inputs</h3>
|
|
53
|
+
<dl class="message-properties">
|
|
54
|
+
<dt>messageIds <span class="property-type">string[]</span></dt>
|
|
55
|
+
<dd>
|
|
56
|
+
The ids to nack. Supplied via <code>msg.messageIds</code>,
|
|
57
|
+
<code>msg.message_ids</code>, or <code>msg.payload</code>.
|
|
58
|
+
</dd>
|
|
59
|
+
<dt class="optional">queue <span class="property-type">string</span></dt>
|
|
60
|
+
<dd>Queue holding the messages.</dd>
|
|
61
|
+
</dl>
|
|
62
|
+
<h3>Outputs</h3>
|
|
63
|
+
<dl class="message-properties">
|
|
64
|
+
<dt>payload <span class="property-type">object</span></dt>
|
|
65
|
+
<dd>Server response with counts of nacked / not-found ids.</dd>
|
|
66
|
+
</dl>
|
|
67
|
+
</script>
|
package/qrusty-nack-batch.js
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
// qrusty-nack-batch.js
|
|
2
|
+
//
|
|
3
|
+
// Batch-negative-acknowledges multiple messages in one HTTP round trip.
|
|
4
|
+
|
|
5
|
+
const { setupActionNode, fromConfigOrMsg } = require("./lib/common");
|
|
6
|
+
|
|
7
|
+
module.exports = function (RED) {
|
|
8
|
+
function QrustyNackBatchNode(n) {
|
|
9
|
+
RED.nodes.createNode(this, n);
|
|
10
|
+
const node = this;
|
|
11
|
+
const server = RED.nodes.getNode(n.server);
|
|
12
|
+
|
|
13
|
+
setupActionNode(node, server, async (client, msg) => {
|
|
14
|
+
const queue = fromConfigOrMsg(n.queue, msg.queue);
|
|
15
|
+
if (!queue) throw new Error("queue is required");
|
|
16
|
+
|
|
17
|
+
const ids = Array.isArray(msg.messageIds)
|
|
18
|
+
? msg.messageIds
|
|
19
|
+
: Array.isArray(msg.message_ids)
|
|
20
|
+
? msg.message_ids
|
|
21
|
+
: Array.isArray(msg.payload)
|
|
22
|
+
? msg.payload
|
|
23
|
+
: null;
|
|
24
|
+
if (!ids || ids.length === 0) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
"messageIds array is required (set msg.messageIds, msg.message_ids, or msg.payload)",
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const consumerId =
|
|
31
|
+
fromConfigOrMsg(n.consumerId, msg.consumer_id) || "node-red-consumer";
|
|
32
|
+
|
|
33
|
+
return await client.nackBatch(queue, consumerId, ids);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
RED.nodes.registerType("qrusty-nack-batch", QrustyNackBatchNode);
|
|
8
38
|
};
|
|
9
|
-
msg.headers = { "Content-Type": "application/json" };
|
|
10
|
-
return msg;
|
package/qrusty-nack.html
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType("qrusty-nack", {
|
|
3
|
+
category: "qrusty",
|
|
4
|
+
color: "#d78a4e",
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: "" },
|
|
7
|
+
server: { value: "", type: "qrusty-server", required: true },
|
|
8
|
+
queue: { value: "" },
|
|
9
|
+
consumerId: { value: "" },
|
|
10
|
+
},
|
|
11
|
+
inputs: 1,
|
|
12
|
+
outputs: 1,
|
|
13
|
+
icon: "font-awesome/fa-times",
|
|
14
|
+
label: function () {
|
|
15
|
+
return this.name || "qrusty nack";
|
|
16
|
+
},
|
|
17
|
+
paletteLabel: "nack",
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script type="text/html" data-template-name="qrusty-nack">
|
|
22
|
+
<div class="form-row">
|
|
23
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
24
|
+
<input type="text" id="node-input-name" placeholder="optional" />
|
|
25
|
+
</div>
|
|
26
|
+
<div class="form-row">
|
|
27
|
+
<label for="node-input-server"><i class="fa fa-server"></i> Server</label>
|
|
28
|
+
<input type="text" id="node-input-server" />
|
|
29
|
+
</div>
|
|
30
|
+
<div class="form-row">
|
|
31
|
+
<label for="node-input-queue"><i class="fa fa-list"></i> Queue</label>
|
|
32
|
+
<input
|
|
33
|
+
type="text"
|
|
34
|
+
id="node-input-queue"
|
|
35
|
+
placeholder="leave blank to use msg.queue"
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="form-row">
|
|
39
|
+
<label for="node-input-consumerId"
|
|
40
|
+
><i class="fa fa-user"></i> Consumer ID</label
|
|
41
|
+
>
|
|
42
|
+
<input
|
|
43
|
+
type="text"
|
|
44
|
+
id="node-input-consumerId"
|
|
45
|
+
placeholder="default node-red-consumer"
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<script type="text/html" data-help-name="qrusty-nack">
|
|
51
|
+
<p>Negatively acknowledges a Qrusty message so it is retried or dead-lettered.</p>
|
|
52
|
+
<h3>Inputs</h3>
|
|
53
|
+
<dl class="message-properties">
|
|
54
|
+
<dt>messageId / id <span class="property-type">string</span></dt>
|
|
55
|
+
<dd>The id of the message to nack.</dd>
|
|
56
|
+
<dt class="optional">queue <span class="property-type">string</span></dt>
|
|
57
|
+
<dd>Queue holding the message.</dd>
|
|
58
|
+
<dt class="optional">consumer_id <span class="property-type">string</span></dt>
|
|
59
|
+
<dd>Consumer identity that originally locked the message.</dd>
|
|
60
|
+
</dl>
|
|
61
|
+
<h3>Outputs</h3>
|
|
62
|
+
<dl class="message-properties">
|
|
63
|
+
<dt>payload <span class="property-type">boolean</span></dt>
|
|
64
|
+
<dd><code>true</code> on success, <code>false</code> if the server returned 404.</dd>
|
|
65
|
+
</dl>
|
|
66
|
+
</script>
|