n8n-nodes-themq 0.4.4
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 +193 -0
- package/dist/credentials/TheMqApi.credentials.d.ts +9 -0
- package/dist/credentials/TheMqApi.credentials.js +47 -0
- package/dist/credentials/TheMqApi.credentials.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/TheMq/TheMq.node.d.ts +18 -0
- package/dist/nodes/TheMq/TheMq.node.js +270 -0
- package/dist/nodes/TheMq/TheMq.node.js.map +1 -0
- package/dist/nodes/TheMq/themq.png +0 -0
- package/dist/nodes/TheMqTrigger/TheMqTrigger.node.d.ts +5 -0
- package/dist/nodes/TheMqTrigger/TheMqTrigger.node.js +558 -0
- package/dist/nodes/TheMqTrigger/TheMqTrigger.node.js.map +1 -0
- package/dist/nodes/TheMqTrigger/themq.png +0 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# n8n-nodes-themq
|
|
2
|
+
|
|
3
|
+
Native n8n community nodes for [TheMQ](../README.md) — a lightweight,
|
|
4
|
+
Redis-backed message broker built around queues and consumers.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
In n8n: **Settings → Community Nodes → Install** → `n8n-nodes-themq`.
|
|
9
|
+
Or `npm install n8n-nodes-themq` in `~/.n8n`, then restart n8n.
|
|
10
|
+
|
|
11
|
+
Add an **TheMQ API** credential: the TheMQ **Base URL**
|
|
12
|
+
(e.g. `http://themq:3000`) and the **API Token** — the `API_TOKEN` value
|
|
13
|
+
pinned in `docker-compose.yml` (overridable via environment).
|
|
14
|
+
|
|
15
|
+
## TheMQ Trigger
|
|
16
|
+
|
|
17
|
+
Listens to a TheMQ queue **over a persistent consumer connection** —
|
|
18
|
+
every message starts an execution immediately. There is no polling
|
|
19
|
+
interval; deactivating the workflow closes the connection and pending
|
|
20
|
+
messages are requeued for redelivery.
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
Credentials
|
|
24
|
+
Queue
|
|
25
|
+
|
|
26
|
+
Options
|
|
27
|
+
+ Acknowledge
|
|
28
|
+
+ Max Concurrent Executions
|
|
29
|
+
+ Max Processing Time (Ms)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Acknowledge
|
|
33
|
+
|
|
34
|
+
Every delivered message is leased, not given away: it must be
|
|
35
|
+
acknowledged, or it comes back. When the acknowledgement happens depends
|
|
36
|
+
on this mode:
|
|
37
|
+
|
|
38
|
+
- **Immediately** — acknowledged as soon as it arrives, with no
|
|
39
|
+
concurrency limit. The workflow still runs, but a later failure can no
|
|
40
|
+
longer return the message. Use it when losing a message on failure is
|
|
41
|
+
acceptable.
|
|
42
|
+
- **Execution Finishes** — acknowledged when the execution finishes,
|
|
43
|
+
whether it succeeded or not.
|
|
44
|
+
- **Execution Finishes Successfully** — acknowledged only on success. On
|
|
45
|
+
failure the message goes back to the queue and is delivered again
|
|
46
|
+
(with `redelivered: true` and a higher `deliveryCount`).
|
|
47
|
+
- **Specified Later in Workflow** — the trigger does not settle. Add an
|
|
48
|
+
**TheMQ → Acknowledge** node where the message is truly done; its
|
|
49
|
+
fields pick up the trigger item automatically. If the run ends without
|
|
50
|
+
acknowledgement, success acknowledges and failure returns the message.
|
|
51
|
+
|
|
52
|
+
Whichever mode you pick, two rules always hold: a message that is still
|
|
53
|
+
unacknowledged when **Max Processing Time** passes is handed out again,
|
|
54
|
+
and a dropped connection returns its pending messages immediately.
|
|
55
|
+
|
|
56
|
+
### Max Concurrent Executions
|
|
57
|
+
|
|
58
|
+
At most this many messages being processed at the same time (default
|
|
59
|
+
`1`). The broker leases no more than this many unacknowledged messages
|
|
60
|
+
to the trigger, so further messages simply wait in the queue until one
|
|
61
|
+
is acknowledged. The option is hidden while Acknowledge is
|
|
62
|
+
`Immediately` — with nothing ever left unacknowledged there is nothing
|
|
63
|
+
to cap, so that mode flows without a limit. Raise the limit when your
|
|
64
|
+
workflow can safely run in parallel.
|
|
65
|
+
|
|
66
|
+
### Max Processing Time (Ms)
|
|
67
|
+
|
|
68
|
+
The lease per message in milliseconds (default `60000`, allowed
|
|
69
|
+
`100`–`43200000`). Each message must be acknowledged within this time
|
|
70
|
+
or it is delivered again to another execution — and may then run twice.
|
|
71
|
+
Set it above your longest run. Delivery is therefore at-least-once:
|
|
72
|
+
keep your workflow idempotent if duplicates would hurt.
|
|
73
|
+
|
|
74
|
+
A message that keeps failing will keep coming back. To stop the loop,
|
|
75
|
+
check `deliveryCount` with an IF node and route poison messages to an
|
|
76
|
+
**TheMQ → Acknowledge** node — acknowledging removes them for good.
|
|
77
|
+
(The **Delete Message** operation is for messages still waiting in the
|
|
78
|
+
queue, not for ones already delivered.)
|
|
79
|
+
|
|
80
|
+
### Output item
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"queue": "orders",
|
|
85
|
+
"messageId": "order-42",
|
|
86
|
+
"consumerId": "cons_abc",
|
|
87
|
+
"data": { "message": "hello" },
|
|
88
|
+
"deliveryCount": 1,
|
|
89
|
+
"redelivered": false
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Troubleshooting
|
|
94
|
+
|
|
95
|
+
**"Timed out waiting for the TheMQ hello reply" on activation.**
|
|
96
|
+
The trigger opened the connection but the server never answered. Check,
|
|
97
|
+
in order:
|
|
98
|
+
|
|
99
|
+
1. TheMQ is **3.0.0+** and reachable from n8n:
|
|
100
|
+
`docker compose pull && docker compose up -d`, then
|
|
101
|
+
`curl http://<host>:3000/health/ready`.
|
|
102
|
+
2. Redis is healthy (`/health/ready` returns 200, not 503).
|
|
103
|
+
3. The TheMQ logs around activation (`docker compose logs themq`):
|
|
104
|
+
`Consumer connected` means the hello succeeded; `subscribe-failed` /
|
|
105
|
+
`frame-failed` entries explain the refusal.
|
|
106
|
+
|
|
107
|
+
**Node shows "TheMQ is not reachable".** The Base URL in your credential
|
|
108
|
+
is wrong or TheMQ is down. Verify with
|
|
109
|
+
`curl http://<host>:3000/health/live` from the n8n host.
|
|
110
|
+
|
|
111
|
+
**"UNAUTHENTICATED".** The API Token in your credential is wrong or stale.
|
|
112
|
+
Fetch the current one from Redis or pin `API_TOKEN`.
|
|
113
|
+
|
|
114
|
+
## TheMQ node
|
|
115
|
+
|
|
116
|
+
Exactly three operations — nothing else:
|
|
117
|
+
|
|
118
|
+
```text
|
|
119
|
+
Publish · Acknowledge · Delete Message
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
- **Publish** — Queue, Message ID (required; the upsert key), Message
|
|
123
|
+
Data, Upsert flag (update the ID in place instead of conflicting),
|
|
124
|
+
Delay (wait before the message becomes available).
|
|
125
|
+
- **Acknowledge** — marks a trigger-delivered message as successfully
|
|
126
|
+
processed. Queue, Message ID, and Consumer ID default to the trigger
|
|
127
|
+
item, so no wiring is needed.
|
|
128
|
+
- **Delete Message** — removes a waiting message so it is never
|
|
129
|
+
processed. Queue and Message ID default to the trigger item.
|
|
130
|
+
|
|
131
|
+
```text
|
|
132
|
+
TheMQ Trigger (Specified Later in Workflow)
|
|
133
|
+
↓
|
|
134
|
+
Process
|
|
135
|
+
↓
|
|
136
|
+
TheMQ → Acknowledge
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Or automatic:
|
|
140
|
+
|
|
141
|
+
```text
|
|
142
|
+
TheMQ Trigger (Execution Finishes Successfully)
|
|
143
|
+
↓
|
|
144
|
+
Process
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Examples
|
|
148
|
+
|
|
149
|
+
Publish from any workflow (Message ID is required — it is the upsert key;
|
|
150
|
+
tick **Upsert** to update an existing ID instead of conflicting):
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
Schedule Trigger → TheMQ (Publish: queue "orders", id "order-42", data {...})
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Competing workers — two activated workflows with triggers on the same
|
|
157
|
+
queue each get different messages, FIFO.
|
|
158
|
+
|
|
159
|
+
Drop a queued message before it is ever delivered:
|
|
160
|
+
|
|
161
|
+
```text
|
|
162
|
+
TheMQ → Delete Message
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Development
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
npm install
|
|
169
|
+
npm run typecheck
|
|
170
|
+
npm run lint
|
|
171
|
+
npm run format
|
|
172
|
+
npm run build # tsc -> dist/ (+ icons)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Publish
|
|
176
|
+
|
|
177
|
+
Releases are published to npm by the [`publish-n8n`
|
|
178
|
+
workflow](../.github/workflows/publish-n8n.yml), which uses the
|
|
179
|
+
`NPM_TOKEN` repository secret:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
npm version patch|minor|major # bumps n8n-nodes-themq/package.json
|
|
183
|
+
git push origin main
|
|
184
|
+
git tag n8n-nodes-themq-v0.4.4 # must match package.json
|
|
185
|
+
git push origin n8n-nodes-themq-v0.4.4
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Pushing the tag builds, verifies, and runs `npm publish --access public`.
|
|
189
|
+
Manual publish (needs an npm token with 2FA bypass or `--otp`):
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
npm publish --access public
|
|
193
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from "n8n-workflow";
|
|
2
|
+
export declare class TheMqApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TheMqApi = void 0;
|
|
4
|
+
class TheMqApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = "theMqApi";
|
|
7
|
+
this.displayName = "TheMQ API";
|
|
8
|
+
this.documentationUrl = "https://github.com/muhammad-sho/TheMQ/tree/main/n8n-nodes-themq";
|
|
9
|
+
this.properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: "Base URL",
|
|
12
|
+
name: "baseUrl",
|
|
13
|
+
type: "string",
|
|
14
|
+
default: "http://localhost:3000",
|
|
15
|
+
placeholder: "http://themq:3000",
|
|
16
|
+
description: "Base URL of the TheMQ HTTP API (no trailing slash)",
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
displayName: "API Token",
|
|
21
|
+
name: "apiToken",
|
|
22
|
+
type: "string",
|
|
23
|
+
typeOptions: { password: true },
|
|
24
|
+
default: "",
|
|
25
|
+
description: "Bearer token: the API_TOKEN value pinned in docker-compose.yml (or your override)",
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
this.authenticate = {
|
|
30
|
+
type: "generic",
|
|
31
|
+
properties: {
|
|
32
|
+
headers: {
|
|
33
|
+
Authorization: "=Bearer {{$credentials.apiToken}}",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
this.test = {
|
|
38
|
+
request: {
|
|
39
|
+
baseURL: "={{$credentials.baseUrl}}",
|
|
40
|
+
url: "/queues",
|
|
41
|
+
method: "GET",
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.TheMqApi = TheMqApi;
|
|
47
|
+
//# sourceMappingURL=TheMqApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TheMqApi.credentials.js","sourceRoot":"","sources":["../../credentials/TheMqApi.credentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,QAAQ;IAArB;QACE,SAAI,GAAG,UAAU,CAAC;QAElB,gBAAW,GAAG,WAAW,CAAC;QAE1B,qBAAgB,GAAG,iEAAiE,CAAC;QAErF,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,uBAAuB;gBAChC,WAAW,EAAE,mBAAmB;gBAChC,WAAW,EAAE,oDAAoD;gBACjE,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,WAAW,EAAE,WAAW;gBACxB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,WAAW,EACT,mFAAmF;gBACrF,QAAQ,EAAE,IAAI;aACf;SACF,CAAC;QAEF,iBAAY,GAAyB;YACnC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,aAAa,EAAE,mCAAmC;iBACnD;aACF;SACF,CAAC;QAEF,SAAI,GAA2B;YAC7B,OAAO,EAAE;gBACP,OAAO,EAAE,2BAA2B;gBACpC,GAAG,EAAE,SAAS;gBACd,MAAM,EAAE,KAAK;aACd;SACF,CAAC;IACJ,CAAC;CAAA;AA7CD,4BA6CC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from "n8n-workflow";
|
|
2
|
+
export declare class TheMq implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
6
|
+
export interface RequestContext {
|
|
7
|
+
itemIndex: number;
|
|
8
|
+
operation: string;
|
|
9
|
+
queue?: string;
|
|
10
|
+
messageId?: string;
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function describeApiError(error: unknown, context: {
|
|
14
|
+
operation: string;
|
|
15
|
+
queue?: string;
|
|
16
|
+
messageId?: string;
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
}): string;
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TheMq = void 0;
|
|
4
|
+
exports.describeApiError = describeApiError;
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
/** Narrow an API value to n8n's item-data type. */
|
|
7
|
+
function toDataObject(value) {
|
|
8
|
+
if (typeof value === "object" && value !== null)
|
|
9
|
+
return value;
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
/** Narrow node parameters explicitly. */
|
|
13
|
+
function strParam(value, fallback = "") {
|
|
14
|
+
return typeof value === "string" ? value : fallback;
|
|
15
|
+
}
|
|
16
|
+
function numParam(value, fallback) {
|
|
17
|
+
return typeof value === "number" ? value : fallback;
|
|
18
|
+
}
|
|
19
|
+
class TheMq {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.description = {
|
|
22
|
+
displayName: "TheMQ",
|
|
23
|
+
name: "theMq",
|
|
24
|
+
icon: "file:themq.png",
|
|
25
|
+
group: ["transform"],
|
|
26
|
+
version: 1,
|
|
27
|
+
subtitle: '={{$parameter["operation"]}}',
|
|
28
|
+
description: "Publish and settle messages in TheMQ queues",
|
|
29
|
+
defaults: {
|
|
30
|
+
name: "TheMQ",
|
|
31
|
+
},
|
|
32
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
33
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
34
|
+
credentials: [
|
|
35
|
+
{
|
|
36
|
+
name: "theMqApi",
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
properties: [
|
|
41
|
+
{
|
|
42
|
+
displayName: "Operation",
|
|
43
|
+
name: "operation",
|
|
44
|
+
type: "options",
|
|
45
|
+
noDataExpression: true,
|
|
46
|
+
options: [
|
|
47
|
+
{
|
|
48
|
+
name: "Publish",
|
|
49
|
+
value: "publish",
|
|
50
|
+
description: "Publish a message to a queue",
|
|
51
|
+
action: "Publish a message",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "Acknowledge",
|
|
55
|
+
value: "ack",
|
|
56
|
+
description: "Mark a trigger-delivered message as successfully processed (also resolves a waiting 'Specified Later in Workflow' trigger)",
|
|
57
|
+
action: "Acknowledge a message",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "Delete Message",
|
|
61
|
+
value: "delete",
|
|
62
|
+
description: "Delete a waiting message so it is never processed",
|
|
63
|
+
action: "Delete a message",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
default: "publish",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
displayName: "Queue",
|
|
70
|
+
name: "queue",
|
|
71
|
+
type: "string",
|
|
72
|
+
// Taken from the trigger item when connected.
|
|
73
|
+
default: "={{ $json.queue }}",
|
|
74
|
+
required: true,
|
|
75
|
+
description: "Name of the queue (taken from the trigger item when connected)",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
displayName: "Message ID",
|
|
79
|
+
name: "messageId",
|
|
80
|
+
type: "string",
|
|
81
|
+
// Taken from the trigger item when connected.
|
|
82
|
+
default: "={{ $json.messageId }}",
|
|
83
|
+
required: true,
|
|
84
|
+
description: "Unique id of the message. When publishing this is the upsert key; when acknowledging or deleting it is taken from the trigger item when connected.",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
displayName: "Message Data",
|
|
88
|
+
name: "messageData",
|
|
89
|
+
type: "json",
|
|
90
|
+
default: '{\n "message": "hello"\n}',
|
|
91
|
+
required: true,
|
|
92
|
+
displayOptions: { show: { operation: ["publish"] } },
|
|
93
|
+
description: "Arbitrary JSON payload — a message is simply a message",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
displayName: "Upsert",
|
|
97
|
+
name: "upsert",
|
|
98
|
+
type: "boolean",
|
|
99
|
+
default: false,
|
|
100
|
+
displayOptions: { show: { operation: ["publish"] } },
|
|
101
|
+
description: "Update the message in place when the ID already exists (new data and delay), instead of failing with a conflict.",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
displayName: "Delay (Ms)",
|
|
105
|
+
name: "ttlMs",
|
|
106
|
+
type: "number",
|
|
107
|
+
default: 0,
|
|
108
|
+
displayOptions: { show: { operation: ["publish"] } },
|
|
109
|
+
description: "Wait this long before the message becomes available (0 = immediately)",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
displayName: "Consumer ID",
|
|
113
|
+
name: "consumerId",
|
|
114
|
+
type: "string",
|
|
115
|
+
// Taken from the trigger item when connected.
|
|
116
|
+
default: "={{ $json.consumerId }}",
|
|
117
|
+
displayOptions: { show: { operation: ["ack"] } },
|
|
118
|
+
description: "Consumer holding the lease (taken from the trigger item when connected). Only change this to settle another consumer's message.",
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async execute() {
|
|
124
|
+
var _a;
|
|
125
|
+
const items = this.getInputData();
|
|
126
|
+
const returnData = [];
|
|
127
|
+
const operation = strParam(this.getNodeParameter("operation", 0));
|
|
128
|
+
for (let i = 0; i < items.length; i++) {
|
|
129
|
+
const queue = strParam(this.getNodeParameter("queue", i, ""));
|
|
130
|
+
const messageId = strParam(this.getNodeParameter("messageId", i, "")).trim();
|
|
131
|
+
try {
|
|
132
|
+
if (queue === "") {
|
|
133
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Queue is required.", { itemIndex: i });
|
|
134
|
+
}
|
|
135
|
+
if (messageId === "") {
|
|
136
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Message ID is required.", {
|
|
137
|
+
itemIndex: i,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (operation === "publish") {
|
|
141
|
+
const dataParam = this.getNodeParameter("messageData", i);
|
|
142
|
+
const data = typeof dataParam === "string" ? JSON.parse(dataParam) : dataParam;
|
|
143
|
+
const ttlMs = numParam(this.getNodeParameter("ttlMs", i, 0), 0);
|
|
144
|
+
const upsert = this.getNodeParameter("upsert", i, false);
|
|
145
|
+
const body = { id: messageId, data };
|
|
146
|
+
if (ttlMs > 0)
|
|
147
|
+
body["ttlMs"] = ttlMs;
|
|
148
|
+
if (upsert === true)
|
|
149
|
+
body["upsert"] = true;
|
|
150
|
+
const response = await request.call(this, "POST", `/queues/${encode(queue)}/messages`, body, { itemIndex: i, operation, queue, messageId });
|
|
151
|
+
returnData.push({ json: toDataObject(response) });
|
|
152
|
+
}
|
|
153
|
+
else if (operation === "ack") {
|
|
154
|
+
const consumerId = strParam(this.getNodeParameter("consumerId", i, "")).trim();
|
|
155
|
+
const body = {};
|
|
156
|
+
if (consumerId !== "")
|
|
157
|
+
body["consumerId"] = consumerId;
|
|
158
|
+
const response = toDataObject(await request.call(this, "POST", `/queues/${encode(queue)}/messages/${encode(messageId)}/ack`, body, { itemIndex: i, operation, queue, messageId }));
|
|
159
|
+
// Resolve a waiting trigger fast (best-effort: the HTTP
|
|
160
|
+
// acknowledgement above already settled).
|
|
161
|
+
try {
|
|
162
|
+
this.sendResponse({ ...(_a = items[i]) === null || _a === void 0 ? void 0 : _a.json, acknowledged: true });
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
// ignore — standalone acknowledgement already succeeded
|
|
166
|
+
}
|
|
167
|
+
returnData.push({ json: { queue, messageId, acked: true, ...response } });
|
|
168
|
+
}
|
|
169
|
+
else if (operation === "delete") {
|
|
170
|
+
await request.call(this, "DELETE", `/queues/${encode(queue)}/messages/${encode(messageId)}`, undefined, { itemIndex: i, operation, queue, messageId });
|
|
171
|
+
returnData.push({ json: { queue, messageId, deleted: true } });
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation "${operation}".`, {
|
|
175
|
+
itemIndex: i,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
if (this.continueOnFail()) {
|
|
181
|
+
returnData.push({
|
|
182
|
+
json: { error: error instanceof Error ? error.message : String(error) },
|
|
183
|
+
pairedItem: { item: i },
|
|
184
|
+
});
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return [returnData];
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.TheMq = TheMq;
|
|
194
|
+
function encode(value) {
|
|
195
|
+
return encodeURIComponent(value);
|
|
196
|
+
}
|
|
197
|
+
async function request(method, path, body, context) {
|
|
198
|
+
var _a;
|
|
199
|
+
const credentials = (await this.getCredentials("theMqApi"));
|
|
200
|
+
const baseUrl = ((_a = credentials.baseUrl) !== null && _a !== void 0 ? _a : "").replace(/\/+$/, "");
|
|
201
|
+
try {
|
|
202
|
+
return toDataObject(await this.helpers.requestWithAuthentication.call(this, "theMqApi", {
|
|
203
|
+
method,
|
|
204
|
+
baseURL: baseUrl,
|
|
205
|
+
url: path,
|
|
206
|
+
...(body !== undefined ? { body } : {}),
|
|
207
|
+
json: true,
|
|
208
|
+
}));
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), describeApiError(error, { ...context, baseUrl }), {
|
|
212
|
+
itemIndex: context.itemIndex,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/** Next step per TheMQ error code (empty = the message says it all). */
|
|
217
|
+
function hintForCode(code, operation) {
|
|
218
|
+
switch (code) {
|
|
219
|
+
case "UNAUTHENTICATED":
|
|
220
|
+
return "Check the API Token in your TheMQ API credential.";
|
|
221
|
+
case "NOT_FOUND":
|
|
222
|
+
return "The queue or message does not exist, or was already removed.";
|
|
223
|
+
case "CONFLICT":
|
|
224
|
+
if (operation === "publish") {
|
|
225
|
+
return "A message with this ID already exists. Enable Upsert to update it.";
|
|
226
|
+
}
|
|
227
|
+
if (operation === "ack") {
|
|
228
|
+
return "The message is not leased to this consumer. It may already be settled, expired, or held by another consumer — check the Consumer ID.";
|
|
229
|
+
}
|
|
230
|
+
return "The message is leased (unacked). Acknowledge it first.";
|
|
231
|
+
case "SERVICE_UNAVAILABLE":
|
|
232
|
+
return "TheMQ cannot reach its Redis backend. Check the TheMQ server.";
|
|
233
|
+
default:
|
|
234
|
+
return "";
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function describeApiError(error, context) {
|
|
238
|
+
var _a, _b, _c, _d;
|
|
239
|
+
const where = [context.operation, context.queue ? `queue "${context.queue}"` : ""]
|
|
240
|
+
.filter((part) => part !== "")
|
|
241
|
+
.join(" ");
|
|
242
|
+
const id = context.messageId ? ` message "${context.messageId}"` : "";
|
|
243
|
+
const record = (typeof error === "object" && error !== null ? error : {});
|
|
244
|
+
// n8n's message is generic per-status text; the real TheMQ body
|
|
245
|
+
// survives at response.data, cause.response.data, or context.data.
|
|
246
|
+
const bodies = [(_a = record.response) === null || _a === void 0 ? void 0 : _a.data, (_c = (_b = record.cause) === null || _b === void 0 ? void 0 : _b.response) === null || _c === void 0 ? void 0 : _c.data, (_d = record.context) === null || _d === void 0 ? void 0 : _d.data];
|
|
247
|
+
for (const body of bodies) {
|
|
248
|
+
if (typeof body !== "object" || body === null || !("error" in body))
|
|
249
|
+
continue;
|
|
250
|
+
const apiError = body.error;
|
|
251
|
+
if (typeof apiError !== "object" || apiError === null)
|
|
252
|
+
continue;
|
|
253
|
+
const { code, message } = apiError;
|
|
254
|
+
if (typeof code === "string" && typeof message === "string") {
|
|
255
|
+
const hint = hintForCode(code, context.operation);
|
|
256
|
+
return `TheMQ ${code}: ${message} [${where}${id}]${hint === "" ? "" : ` ${hint}`}`;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Error status with an unfamiliar body: n8n copies the text into `description`.
|
|
260
|
+
const httpCode = typeof record.httpCode === "string" ? record.httpCode : "";
|
|
261
|
+
const description = typeof record.description === "string" ? record.description : "";
|
|
262
|
+
if (httpCode !== "" && description !== "") {
|
|
263
|
+
return `TheMQ HTTP ${httpCode}: ${description} [${where}${id}]`;
|
|
264
|
+
}
|
|
265
|
+
// No API body: transport-level failure (DNS, refused, timeout, proxy).
|
|
266
|
+
const message = typeof record.message === "string" ? record.message : "";
|
|
267
|
+
const at = context.baseUrl ? ` at ${context.baseUrl}` : "";
|
|
268
|
+
return `TheMQ is not reachable${at} [${where}${id}]${message === "" ? "" : `: ${message}`} Check that TheMQ is running and the Base URL in your credential is correct.`;
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=TheMq.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TheMq.node.js","sourceRoot":"","sources":["../../../nodes/TheMq/TheMq.node.ts"],"names":[],"mappings":";;;AAuRA,4CAuCC;AArTD,+CAAuE;AAEvE,mDAAmD;AACnD,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAoB,CAAC;IAC7E,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,yCAAyC;AACzC,SAAS,QAAQ,CAAC,KAAsC,EAAE,QAAQ,GAAG,EAAE;IACrE,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AACtD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAsC,EAAE,QAAgB;IACxE,OAAO,OAAO,KA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CAAC,EAAE,CAAC;IACzE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3D,OAAO,yBAAyB,EAAE,KAAK,KAAK,GAAG,EAAE,IAAI,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,8EAA8E,CAAC;AAC1K,CAAC"}
|
|
Binary file
|
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TheMqTrigger = void 0;
|
|
7
|
+
const ws_1 = __importDefault(require("ws"));
|
|
8
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
9
|
+
const TheMq_node_js_1 = require("../TheMq/TheMq.node.js");
|
|
10
|
+
/** A message the broker failed to settle because it is already gone. */
|
|
11
|
+
function isAlreadySettled(error) {
|
|
12
|
+
if (typeof error !== "object" || error === null)
|
|
13
|
+
return false;
|
|
14
|
+
const message = error.message;
|
|
15
|
+
return (typeof message === "string" && (message.includes("NOT_FOUND") || message.includes("CONFLICT")));
|
|
16
|
+
}
|
|
17
|
+
/** Narrow an unknown frame field to a string (never stringifies objects). */
|
|
18
|
+
function frameString(value) {
|
|
19
|
+
return typeof value === "string" ? value : "";
|
|
20
|
+
}
|
|
21
|
+
/** Decode a WebSocket frame payload to text. */
|
|
22
|
+
function frameText(raw) {
|
|
23
|
+
if (typeof raw === "string")
|
|
24
|
+
return raw;
|
|
25
|
+
if (Array.isArray(raw))
|
|
26
|
+
return Buffer.concat(raw).toString("utf8");
|
|
27
|
+
if (raw instanceof ArrayBuffer)
|
|
28
|
+
return Buffer.from(raw).toString("utf8");
|
|
29
|
+
return raw.toString("utf8");
|
|
30
|
+
}
|
|
31
|
+
function sleep(ms) {
|
|
32
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
33
|
+
}
|
|
34
|
+
/** Connect failure in plain language (raw socket errors are cryptic). */
|
|
35
|
+
function describeConnectionError(error, queue, baseUrl) {
|
|
36
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
37
|
+
if (/401|unauthorized/i.test(message)) {
|
|
38
|
+
return `TheMQ rejected the connection for queue "${queue}" (unauthorized). Check the API Token in your TheMQ API credential.`;
|
|
39
|
+
}
|
|
40
|
+
return (`TheMQ is not reachable at ${baseUrl} for queue "${queue}": ${message} ` +
|
|
41
|
+
"Check that TheMQ is running and the Base URL in your credential is correct.");
|
|
42
|
+
}
|
|
43
|
+
class TheMqTrigger {
|
|
44
|
+
constructor() {
|
|
45
|
+
this.description = {
|
|
46
|
+
displayName: "TheMQ Trigger",
|
|
47
|
+
name: "theMqTrigger",
|
|
48
|
+
icon: "file:themq.png",
|
|
49
|
+
group: ["trigger"],
|
|
50
|
+
version: 1,
|
|
51
|
+
description: "Listens to TheMQ messages",
|
|
52
|
+
defaults: {
|
|
53
|
+
name: "TheMQ Trigger",
|
|
54
|
+
},
|
|
55
|
+
triggerPanel: {
|
|
56
|
+
header: "",
|
|
57
|
+
executionsHelp: {
|
|
58
|
+
inactive: "<b>While building your workflow</b>, click the 'execute step' button, then publish a message to the TheMQ queue. This will trigger an execution, which will show up in this editor.<br /> <br /><b>Once you're happy with your workflow</b>, publish it. Then every time a message arrives, the workflow will execute. These executions will show up in the <a data-key='executions'>executions list</a>, but not in the editor.",
|
|
59
|
+
active: "<b>While building your workflow</b>, click the 'execute step' button, then publish a message to the TheMQ queue. This will trigger an execution, which will show up in this editor.<br /> <br /><b>Your workflow will also execute automatically</b>, since it's activated. Every time a message arrives, this node will trigger an execution. These executions will show up in the <a data-key='executions'>executions list</a>, but not in the editor.",
|
|
60
|
+
},
|
|
61
|
+
activationHint: "Once you've finished building your workflow, publish it to have it also listen continuously (you just won't see those executions here).",
|
|
62
|
+
},
|
|
63
|
+
inputs: [],
|
|
64
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
65
|
+
credentials: [
|
|
66
|
+
{
|
|
67
|
+
name: "theMqApi",
|
|
68
|
+
required: true,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
properties: [
|
|
72
|
+
{
|
|
73
|
+
displayName: "Queue",
|
|
74
|
+
name: "queue",
|
|
75
|
+
type: "string",
|
|
76
|
+
default: "",
|
|
77
|
+
required: true,
|
|
78
|
+
placeholder: "queue-name",
|
|
79
|
+
description: "The name of the queue to listen to (declared automatically if missing)",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
displayName: "Options",
|
|
83
|
+
name: "options",
|
|
84
|
+
type: "collection",
|
|
85
|
+
default: {},
|
|
86
|
+
placeholder: "Add option",
|
|
87
|
+
options: [
|
|
88
|
+
{
|
|
89
|
+
displayName: "Acknowledge",
|
|
90
|
+
name: "acknowledge",
|
|
91
|
+
type: "options",
|
|
92
|
+
options: [
|
|
93
|
+
{
|
|
94
|
+
name: "Execution Finishes",
|
|
95
|
+
value: "executionFinishes",
|
|
96
|
+
description: "After the workflow execution finished. The message is acknowledged whether the execution was successful or not.",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "Execution Finishes Successfully",
|
|
100
|
+
value: "executionFinishesSuccessfully",
|
|
101
|
+
description: "After the workflow execution finished successfully. On failure the message goes back to the queue and is delivered again.",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "Immediately",
|
|
105
|
+
value: "immediately",
|
|
106
|
+
description: "As soon as the message arrives, without a concurrency limit. The workflow still runs, but a failure can no longer return the message.",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "Specified Later in Workflow",
|
|
110
|
+
value: "laterMessageNode",
|
|
111
|
+
description: "Using an TheMQ node to acknowledge the message. If the run ends without one, success acknowledges and failure returns the message.",
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
default: "immediately",
|
|
115
|
+
description: "When to acknowledge the message",
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
displayName: "Max Concurrent Executions",
|
|
119
|
+
name: "maxConcurrentExecutions",
|
|
120
|
+
type: "number",
|
|
121
|
+
default: 1,
|
|
122
|
+
displayOptions: {
|
|
123
|
+
hide: {
|
|
124
|
+
acknowledge: ["immediately"],
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
description: "At most this many messages being processed at the same time. Further messages wait in the queue until one is acknowledged.",
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
displayName: "Max Processing Time (Ms)",
|
|
131
|
+
name: "visibilityTimeoutMs",
|
|
132
|
+
type: "number",
|
|
133
|
+
default: 60000,
|
|
134
|
+
description: "Lease per message in milliseconds (100 to 43200000). Each message must be acknowledged within this time or it is handed out again and may run twice. Set it above your longest run.",
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
displayName: "To acknowledge the message, insert an TheMQ node later in the workflow and use the 'Acknowledge' operation",
|
|
140
|
+
name: "laterMessageNode",
|
|
141
|
+
type: "notice",
|
|
142
|
+
displayOptions: {
|
|
143
|
+
show: {
|
|
144
|
+
"/options.acknowledge": ["laterMessageNode"],
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
default: "",
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async trigger() {
|
|
153
|
+
var _a, _b, _c, _d, _e;
|
|
154
|
+
const queue = this.getNodeParameter("queue");
|
|
155
|
+
const options = this.getNodeParameter("options", {});
|
|
156
|
+
const acknowledgeMode = (_a = options.acknowledge) !== null && _a !== void 0 ? _a : "immediately";
|
|
157
|
+
const maxConcurrent = (_b = options.maxConcurrentExecutions) !== null && _b !== void 0 ? _b : 1;
|
|
158
|
+
if (acknowledgeMode !== "immediately") {
|
|
159
|
+
if (!Number.isInteger(maxConcurrent) || maxConcurrent < 1) {
|
|
160
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Max Concurrent Executions must be an integer greater than zero.");
|
|
161
|
+
}
|
|
162
|
+
if (maxConcurrent > 1000) {
|
|
163
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Max Concurrent Executions must be at most 1000.");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const visibilityTimeoutMs = (_c = options.visibilityTimeoutMs) !== null && _c !== void 0 ? _c : 60000;
|
|
167
|
+
if (!Number.isInteger(visibilityTimeoutMs) ||
|
|
168
|
+
visibilityTimeoutMs < 100 ||
|
|
169
|
+
visibilityTimeoutMs > 43200000) {
|
|
170
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Max Processing Time must be an integer between 100 and 43200000 milliseconds.");
|
|
171
|
+
}
|
|
172
|
+
// Consumer identity is server-generated, so workflows never share a
|
|
173
|
+
// lease by accident. Immediately is uncapped (server maximum);
|
|
174
|
+
// otherwise the broker leases at most Max Concurrent Executions.
|
|
175
|
+
const prefetch = acknowledgeMode === "immediately" ? 1000 : maxConcurrent;
|
|
176
|
+
const credentials = (await this.getCredentials("theMqApi"));
|
|
177
|
+
const baseUrl = ((_d = credentials.baseUrl) !== null && _d !== void 0 ? _d : "").replace(/\/+$/, "");
|
|
178
|
+
const apiToken = (_e = credentials.apiToken) !== null && _e !== void 0 ? _e : "";
|
|
179
|
+
const wsUrl = `${baseUrl.replace(/^http/, "ws")}/queues/${encodeURIComponent(queue)}/subscribe`;
|
|
180
|
+
// Idempotent declare so listening on a fresh queue does not fail.
|
|
181
|
+
try {
|
|
182
|
+
await this.helpers.requestWithAuthentication.call(this, "theMqApi", {
|
|
183
|
+
method: "PUT",
|
|
184
|
+
baseURL: baseUrl,
|
|
185
|
+
url: `/queues/${encodeURIComponent(queue)}`,
|
|
186
|
+
body: {},
|
|
187
|
+
json: true,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), (0, TheMq_node_js_1.describeApiError)(error, { operation: "declare queue", queue, baseUrl }));
|
|
192
|
+
}
|
|
193
|
+
const inflight = new Set();
|
|
194
|
+
const pendingSettles = new Map();
|
|
195
|
+
let closeGotCalled = false;
|
|
196
|
+
let socket;
|
|
197
|
+
let activeConsumerId = "";
|
|
198
|
+
const logError = (message) => {
|
|
199
|
+
const workflow = this.getWorkflow();
|
|
200
|
+
const node = this.getNode();
|
|
201
|
+
this.logger.error(`There was a problem with the TheMQ Trigger node "${node.name}" in workflow "${workflow.id}": "${message}"`, { node: node.name, workflowId: workflow.id });
|
|
202
|
+
};
|
|
203
|
+
const openSocket = async () => {
|
|
204
|
+
const candidate = new ws_1.default(wsUrl, {
|
|
205
|
+
headers: { Authorization: `Bearer ${apiToken}` },
|
|
206
|
+
});
|
|
207
|
+
return new Promise((resolve, reject) => {
|
|
208
|
+
const timer = setTimeout(() => {
|
|
209
|
+
candidate.terminate();
|
|
210
|
+
reject(new Error(`Timed out connecting to TheMQ for queue "${queue}". Check that TheMQ is running and the Base URL in your credential is correct.`));
|
|
211
|
+
}, 15000);
|
|
212
|
+
candidate.once("open", () => {
|
|
213
|
+
clearTimeout(timer);
|
|
214
|
+
resolve(candidate);
|
|
215
|
+
});
|
|
216
|
+
candidate.once("error", (err) => {
|
|
217
|
+
clearTimeout(timer);
|
|
218
|
+
reject(new Error(describeConnectionError(err, queue, baseUrl)));
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
const waitReady = async (candidate) => {
|
|
223
|
+
return new Promise((resolve, reject) => {
|
|
224
|
+
const timer = setTimeout(() => {
|
|
225
|
+
cleanup();
|
|
226
|
+
try {
|
|
227
|
+
candidate.close(1000, "Hello reply timed out");
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
// ignore — socket is already gone
|
|
231
|
+
}
|
|
232
|
+
reject(new Error(`Timed out waiting for the TheMQ hello reply for queue "${queue}" (${wsUrl}). ` +
|
|
233
|
+
"Is TheMQ 3.0.0+ running and reachable from n8n, and is Redis healthy? " +
|
|
234
|
+
"Check the TheMQ logs for subscribe/Redis errors."));
|
|
235
|
+
}, 15000);
|
|
236
|
+
// Deliveries can arrive BEFORE the ready frame — buffer them for
|
|
237
|
+
// replay once the consumer id is known, so none is ever dropped.
|
|
238
|
+
const early = [];
|
|
239
|
+
const cleanup = () => {
|
|
240
|
+
clearTimeout(timer);
|
|
241
|
+
candidate.off("message", onFrame);
|
|
242
|
+
candidate.off("close", onClose);
|
|
243
|
+
};
|
|
244
|
+
const onFrame = (raw) => {
|
|
245
|
+
let frame;
|
|
246
|
+
try {
|
|
247
|
+
frame = JSON.parse(frameText(raw));
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (frame["type"] === "ready" && typeof frame["consumerId"] === "string") {
|
|
253
|
+
cleanup();
|
|
254
|
+
resolve({ consumerId: frame["consumerId"], early });
|
|
255
|
+
}
|
|
256
|
+
else if (frame["type"] === "message" && typeof frame["id"] === "string") {
|
|
257
|
+
early.push({
|
|
258
|
+
id: frame["id"],
|
|
259
|
+
data: frame["data"],
|
|
260
|
+
deliveryCount: typeof frame["deliveryCount"] === "number" ? frame["deliveryCount"] : 1,
|
|
261
|
+
redelivered: frame["redelivered"] === true,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
else if (frame["type"] === "error") {
|
|
265
|
+
cleanup();
|
|
266
|
+
const code = frameString(frame["code"]) || "ERROR";
|
|
267
|
+
const message = frameString(frame["message"]) || "subscribe failed";
|
|
268
|
+
reject(new Error(`TheMQ ${code}: ${message}`));
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const onClose = () => {
|
|
272
|
+
cleanup();
|
|
273
|
+
reject(new Error("TheMQ connection closed before the hello reply"));
|
|
274
|
+
};
|
|
275
|
+
candidate.on("message", onFrame);
|
|
276
|
+
candidate.once("close", onClose);
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
/** Acknowledge/reject over the persistent connection. */
|
|
280
|
+
const sendSettle = (action, id) => {
|
|
281
|
+
return new Promise((resolve, reject) => {
|
|
282
|
+
const current = socket;
|
|
283
|
+
if (!current || current.readyState !== ws_1.default.OPEN) {
|
|
284
|
+
reject(new Error("TheMQ connection is not open"));
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const timer = setTimeout(() => {
|
|
288
|
+
pendingSettles.delete(id);
|
|
289
|
+
reject(new Error("Timed out settling the TheMQ message"));
|
|
290
|
+
}, 10000);
|
|
291
|
+
pendingSettles.set(id, {
|
|
292
|
+
resolve: () => {
|
|
293
|
+
clearTimeout(timer);
|
|
294
|
+
resolve();
|
|
295
|
+
},
|
|
296
|
+
reject: (err) => {
|
|
297
|
+
clearTimeout(timer);
|
|
298
|
+
reject(err);
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
try {
|
|
302
|
+
current.send(JSON.stringify({ action, id }));
|
|
303
|
+
}
|
|
304
|
+
catch (error) {
|
|
305
|
+
pendingSettles.delete(id);
|
|
306
|
+
clearTimeout(timer);
|
|
307
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
const settleAck = async (id) => {
|
|
312
|
+
try {
|
|
313
|
+
await sendSettle("ack", id);
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
// Already settled elsewhere — nothing left to do.
|
|
317
|
+
if (!isAlreadySettled(error))
|
|
318
|
+
throw error;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
const settleRequeue = async (id) => {
|
|
322
|
+
try {
|
|
323
|
+
await sendSettle("requeue", id);
|
|
324
|
+
}
|
|
325
|
+
catch (error) {
|
|
326
|
+
if (!isAlreadySettled(error))
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
const routeReplyFrame = (frame) => {
|
|
331
|
+
const id = frame["id"];
|
|
332
|
+
if (typeof id !== "string")
|
|
333
|
+
return;
|
|
334
|
+
const pending = pendingSettles.get(id);
|
|
335
|
+
if (!pending)
|
|
336
|
+
return;
|
|
337
|
+
pendingSettles.delete(id);
|
|
338
|
+
if (frame["type"] === "acked" || frame["type"] === "requeued") {
|
|
339
|
+
pending.resolve();
|
|
340
|
+
}
|
|
341
|
+
else if (frame["type"] === "error") {
|
|
342
|
+
const code = frameString(frame["code"]) || "ERROR";
|
|
343
|
+
const message = frameString(frame["message"]) || "settle failed";
|
|
344
|
+
pending.reject(new Error(`TheMQ ${code}: ${message}`));
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
const toItem = (message) => ({
|
|
348
|
+
json: {
|
|
349
|
+
queue,
|
|
350
|
+
messageId: message.id,
|
|
351
|
+
consumerId: activeConsumerId,
|
|
352
|
+
data: message.data,
|
|
353
|
+
deliveryCount: message.deliveryCount,
|
|
354
|
+
redelivered: message.redelivered,
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
const handleMessage = async (message) => {
|
|
358
|
+
var _a, _b, _c, _d;
|
|
359
|
+
if (closeGotCalled)
|
|
360
|
+
return;
|
|
361
|
+
inflight.add(message.id);
|
|
362
|
+
try {
|
|
363
|
+
const item = toItem(message);
|
|
364
|
+
if (acknowledgeMode === "immediately") {
|
|
365
|
+
this.emit([[item]]);
|
|
366
|
+
await settleAck(message.id);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (acknowledgeMode === "laterMessageNode") {
|
|
370
|
+
const responsePromiseHook = this.helpers.createDeferredPromise();
|
|
371
|
+
// Also await execution end, so a failed run requeues even when
|
|
372
|
+
// no TheMQ node fires first.
|
|
373
|
+
const responsePromise = this.helpers.createDeferredPromise();
|
|
374
|
+
this.emit([[item]], responsePromiseHook, responsePromise);
|
|
375
|
+
const first = await Promise.race([
|
|
376
|
+
responsePromiseHook.promise.then((data) => ({
|
|
377
|
+
kind: "hook",
|
|
378
|
+
real: data !== null && typeof data === "object" && Object.keys(data).length > 0,
|
|
379
|
+
})),
|
|
380
|
+
responsePromise.promise.then((data) => ({ kind: "run", data })),
|
|
381
|
+
]);
|
|
382
|
+
if (first.kind === "hook" && first.real) {
|
|
383
|
+
await settleAck(message.id);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
const run = first.kind === "run" ? first.data : await responsePromise.promise;
|
|
387
|
+
if ((_b = (_a = run === null || run === void 0 ? void 0 : run.data) === null || _a === void 0 ? void 0 : _a.resultData) === null || _b === void 0 ? void 0 : _b.error) {
|
|
388
|
+
await settleRequeue(message.id);
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
await settleAck(message.id);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const responsePromise = this.helpers.createDeferredPromise();
|
|
397
|
+
this.emit([[item]], undefined, responsePromise);
|
|
398
|
+
const run = await responsePromise.promise;
|
|
399
|
+
if ((_d = (_c = run === null || run === void 0 ? void 0 : run.data) === null || _c === void 0 ? void 0 : _c.resultData) === null || _d === void 0 ? void 0 : _d.error) {
|
|
400
|
+
if (acknowledgeMode === "executionFinishesSuccessfully") {
|
|
401
|
+
await settleRequeue(message.id);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
await settleAck(message.id);
|
|
406
|
+
}
|
|
407
|
+
catch (error) {
|
|
408
|
+
logError(`message "${message.id}": ${error instanceof Error ? error.message : String(error)}`);
|
|
409
|
+
}
|
|
410
|
+
finally {
|
|
411
|
+
inflight.delete(message.id);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
const onSocketFrame = (raw) => {
|
|
415
|
+
let frame;
|
|
416
|
+
try {
|
|
417
|
+
frame = JSON.parse(frameText(raw));
|
|
418
|
+
}
|
|
419
|
+
catch {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (frame["type"] === "message" && typeof frame["id"] === "string") {
|
|
423
|
+
void handleMessage({
|
|
424
|
+
id: frame["id"],
|
|
425
|
+
data: frame["data"],
|
|
426
|
+
deliveryCount: typeof frame["deliveryCount"] === "number" ? frame["deliveryCount"] : 1,
|
|
427
|
+
redelivered: frame["redelivered"] === true,
|
|
428
|
+
});
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
if (frame["type"] === "acked" || frame["type"] === "requeued" || frame["type"] === "error") {
|
|
432
|
+
routeReplyFrame(frame);
|
|
433
|
+
if (frame["type"] === "error" && frame["id"] === undefined) {
|
|
434
|
+
const code = frameString(frame["code"]) || "ERROR";
|
|
435
|
+
const message = frameString(frame["message"]);
|
|
436
|
+
logError(message === "" ? `TheMQ ${code}` : `TheMQ ${code}: ${message}`);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
const closeFunction = async () => {
|
|
441
|
+
closeGotCalled = true;
|
|
442
|
+
// Bounded grace period for in-flight executions; leftovers requeue
|
|
443
|
+
// server-side on close.
|
|
444
|
+
let waits = 0;
|
|
445
|
+
while (inflight.size > 0 && waits++ < 60) {
|
|
446
|
+
await sleep(1000);
|
|
447
|
+
}
|
|
448
|
+
for (const [, pending] of pendingSettles) {
|
|
449
|
+
pending.reject(new Error("TheMQ Trigger is closing"));
|
|
450
|
+
}
|
|
451
|
+
pendingSettles.clear();
|
|
452
|
+
const current = socket;
|
|
453
|
+
socket = undefined;
|
|
454
|
+
if (current) {
|
|
455
|
+
await new Promise((resolve) => {
|
|
456
|
+
const timer = setTimeout(resolve, 5000);
|
|
457
|
+
current.once("close", () => {
|
|
458
|
+
clearTimeout(timer);
|
|
459
|
+
resolve();
|
|
460
|
+
});
|
|
461
|
+
try {
|
|
462
|
+
current.close(1000, "Trigger deactivated");
|
|
463
|
+
}
|
|
464
|
+
catch {
|
|
465
|
+
clearTimeout(timer);
|
|
466
|
+
resolve();
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
const connectConsumer = async (helloPrefetch, attachMessageHandler) => {
|
|
472
|
+
const candidate = await openSocket();
|
|
473
|
+
socket = candidate;
|
|
474
|
+
candidate.send(JSON.stringify({
|
|
475
|
+
action: "hello",
|
|
476
|
+
prefetch: helloPrefetch,
|
|
477
|
+
visibilityTimeoutMs,
|
|
478
|
+
}));
|
|
479
|
+
const ready = await waitReady(candidate);
|
|
480
|
+
activeConsumerId = ready.consumerId;
|
|
481
|
+
if (attachMessageHandler) {
|
|
482
|
+
candidate.on("message", onSocketFrame);
|
|
483
|
+
}
|
|
484
|
+
candidate.on("error", (err) => {
|
|
485
|
+
logError(err.message);
|
|
486
|
+
});
|
|
487
|
+
candidate.on("close", (code) => {
|
|
488
|
+
if (socket === candidate)
|
|
489
|
+
socket = undefined;
|
|
490
|
+
for (const [, pending] of pendingSettles) {
|
|
491
|
+
pending.reject(new Error("TheMQ connection closed"));
|
|
492
|
+
}
|
|
493
|
+
pendingSettles.clear();
|
|
494
|
+
if (!closeGotCalled) {
|
|
495
|
+
this.emitError(new Error(`TheMQ connection closed unexpectedly (code ${String(code)})`));
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
return ready.early;
|
|
499
|
+
};
|
|
500
|
+
if (this.getMode() === "manual") {
|
|
501
|
+
const manualTriggerFunction = async () => {
|
|
502
|
+
// Catch one message for the editor test run, then disconnect.
|
|
503
|
+
// No execution hooks here: the test run settles it immediately.
|
|
504
|
+
// Hello uses prefetch 1, so at most one message can arrive early.
|
|
505
|
+
const early = await connectConsumer(1, false);
|
|
506
|
+
const first = early.length > 0
|
|
507
|
+
? early[0]
|
|
508
|
+
: await new Promise((resolve) => {
|
|
509
|
+
const current = socket;
|
|
510
|
+
if (!current) {
|
|
511
|
+
resolve(undefined);
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const onFrame = (raw) => {
|
|
515
|
+
let frame;
|
|
516
|
+
try {
|
|
517
|
+
frame = JSON.parse(frameText(raw));
|
|
518
|
+
}
|
|
519
|
+
catch {
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
if (frame["type"] === "message" && typeof frame["id"] === "string") {
|
|
523
|
+
current.off("message", onFrame);
|
|
524
|
+
resolve({
|
|
525
|
+
id: frame["id"],
|
|
526
|
+
data: frame["data"],
|
|
527
|
+
deliveryCount: typeof frame["deliveryCount"] === "number" ? frame["deliveryCount"] : 1,
|
|
528
|
+
redelivered: frame["redelivered"] === true,
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
current.on("message", onFrame);
|
|
533
|
+
});
|
|
534
|
+
if (first) {
|
|
535
|
+
this.emit([[toItem(first)]]);
|
|
536
|
+
await settleAck(first.id).catch((error) => {
|
|
537
|
+
logError(`message "${first.id}": ${error instanceof Error ? error.message : String(error)}`);
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
await closeFunction();
|
|
541
|
+
};
|
|
542
|
+
return {
|
|
543
|
+
closeFunction,
|
|
544
|
+
manualTriggerFunction,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
const early = await connectConsumer(prefetch, true);
|
|
548
|
+
// Replay pre-ready deliveries through the normal path.
|
|
549
|
+
for (const message of early) {
|
|
550
|
+
void handleMessage(message);
|
|
551
|
+
}
|
|
552
|
+
return {
|
|
553
|
+
closeFunction,
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
exports.TheMqTrigger = TheMqTrigger;
|
|
558
|
+
//# sourceMappingURL=TheMqTrigger.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TheMqTrigger.node.js","sourceRoot":"","sources":["../../../nodes/TheMqTrigger/TheMqTrigger.node.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA2B;AAW3B,+CAAuE;AACvE,0DAA0D;AA6B1D,wEAAwE;AACxE,SAAS,gBAAgB,CA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C,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;oCACzE,WAAW,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,IAAI;iCAC3C,CAAC,CAAC;4BACL,CAAC;wBACH,CAAC,CAAC;wBACF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;oBACjC,CAAC,CAAC,CAAC;gBACT,IAAI,KAAK,EAAE,CAAC;oBACV,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC7B,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;wBACjD,QAAQ,CACN,YAAY,KAAK,CAAC,EAAE,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACnF,CAAC;oBACJ,CAAC,CAAC,CAAC;gBACL,CAAC;gBACD,MAAM,aAAa,EAAE,CAAC;YACxB,CAAC,CAAC;YAEF,OAAO;gBACL,aAAa;gBACb,qBAAqB;aACtB,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACpD,uDAAuD;QACvD,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE,CAAC;YAC5B,KAAK,aAAa,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QAED,OAAO;YACL,aAAa;SACd,CAAC;IACJ,CAAC;CACF;AA9iBD,oCA8iBC"}
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-themq",
|
|
3
|
+
"version": "0.4.4",
|
|
4
|
+
"description": "Native n8n community nodes for TheMQ — a lightweight, Redis-backed queue/consumer message broker.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"n8n-community-node-package",
|
|
7
|
+
"n8n",
|
|
8
|
+
"themq",
|
|
9
|
+
"message-queue",
|
|
10
|
+
"broker"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"homepage": "https://github.com/muhammad-sho/TheMQ/tree/main/n8n-nodes-themq",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "TheMQ contributors"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/muhammad-sho/TheMQ.git",
|
|
20
|
+
"directory": "n8n-nodes-themq"
|
|
21
|
+
},
|
|
22
|
+
"main": "dist/index.js",
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc -p tsconfig.json && npm run copy:icons",
|
|
25
|
+
"copy:icons": "cp nodes/TheMq/themq.png dist/nodes/TheMq/themq.png && cp nodes/TheMqTrigger/themq.png dist/nodes/TheMqTrigger/themq.png",
|
|
26
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
27
|
+
"lint": "eslint credentials nodes index.ts",
|
|
28
|
+
"format": "prettier --write .",
|
|
29
|
+
"format:check": "prettier --check .",
|
|
30
|
+
"prepublishOnly": "npm run build"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"n8n": {
|
|
36
|
+
"n8nNodesApiVersion": 1,
|
|
37
|
+
"credentials": [
|
|
38
|
+
"dist/credentials/TheMqApi.credentials.js"
|
|
39
|
+
],
|
|
40
|
+
"nodes": [
|
|
41
|
+
"dist/nodes/TheMq/TheMq.node.js",
|
|
42
|
+
"dist/nodes/TheMqTrigger/TheMqTrigger.node.js"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^22.0.0",
|
|
47
|
+
"@types/ws": "^8.18.1",
|
|
48
|
+
"eslint": "^9.18.0",
|
|
49
|
+
"n8n-workflow": "^1.0.0",
|
|
50
|
+
"prettier": "^3.4.0",
|
|
51
|
+
"typescript": "^5.7.0",
|
|
52
|
+
"typescript-eslint": "^8.20.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"n8n-workflow": "*"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"ws": "^8.21.3"
|
|
59
|
+
}
|
|
60
|
+
}
|