n8n-nodes-themq 0.8.0 → 0.9.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.

Potentially problematic release.


This version of n8n-nodes-themq might be problematic. Click here for more details.

Files changed (36) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +185 -120
  3. package/dist/nodes/TheMq/TheMq.node.d.ts +3 -20
  4. package/dist/nodes/TheMq/TheMq.node.js +15 -484
  5. package/dist/nodes/TheMq/TheMq.node.js.map +1 -1
  6. package/dist/nodes/TheMq/TheMqV1.node.d.ts +5 -0
  7. package/dist/nodes/TheMq/TheMqV1.node.js +414 -0
  8. package/dist/nodes/TheMq/TheMqV1.node.js.map +1 -0
  9. package/dist/nodes/TheMq/TheMqV2.node.d.ts +6 -0
  10. package/dist/nodes/TheMq/TheMqV2.node.js +276 -0
  11. package/dist/nodes/TheMq/TheMqV2.node.js.map +1 -0
  12. package/dist/nodes/TheMqAck/TheMqAck.node.d.ts +6 -0
  13. package/dist/nodes/TheMqAck/TheMqAck.node.js +69 -0
  14. package/dist/nodes/TheMqAck/TheMqAck.node.js.map +1 -0
  15. package/dist/nodes/TheMqAck/themq.png +0 -0
  16. package/dist/nodes/TheMqTrigger/TheMqTrigger.node.js +64 -120
  17. package/dist/nodes/TheMqTrigger/TheMqTrigger.node.js.map +1 -1
  18. package/dist/nodes/shared/errors.d.ts +13 -0
  19. package/dist/nodes/shared/errors.js +99 -0
  20. package/dist/nodes/shared/errors.js.map +1 -0
  21. package/dist/nodes/shared/frames.d.ts +15 -0
  22. package/dist/nodes/shared/frames.js +44 -0
  23. package/dist/nodes/shared/frames.js.map +1 -0
  24. package/dist/nodes/shared/http.d.ts +15 -0
  25. package/dist/nodes/shared/http.js +28 -0
  26. package/dist/nodes/shared/http.js.map +1 -0
  27. package/dist/nodes/shared/messages.d.ts +12 -0
  28. package/dist/nodes/shared/messages.js +40 -0
  29. package/dist/nodes/shared/messages.js.map +1 -0
  30. package/dist/nodes/shared/params.d.ts +7 -0
  31. package/dist/nodes/shared/params.js +23 -0
  32. package/dist/nodes/shared/params.js.map +1 -0
  33. package/dist/nodes/shared/request.d.ts +4 -0
  34. package/dist/nodes/shared/request.js +26 -0
  35. package/dist/nodes/shared/request.js.map +1 -0
  36. package/package.json +5 -3
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 TheMQ contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,82 +1,118 @@
1
1
  # n8n-nodes-themq
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/n8n-nodes-themq.svg)](https://www.npmjs.com/package/n8n-nodes-themq)
4
- [![license](https://img.shields.io/badge/license-ISC-blue.svg)](../LICENSE)
4
+ [![license](https://img.shields.io/badge/license-ISC-blue.svg)](LICENSE)
5
5
 
6
- Native n8n community nodes for [TheMQ](https://github.com/muhammad-sho/TheMQ) — a lightweight,
7
- Redis-backed message broker built around queues and consumers.
6
+ Native n8n community nodes for [TheMQ](https://github.com/muhammad-sho/TheMQ) —
7
+ a lightweight, Redis-backed message broker built around queues and consumers.
8
+
9
+ - **TheMQ Trigger** starts one workflow execution per message over a persistent
10
+ consumer connection.
11
+ - **TheMQ Publish** publishes messages and applies clear on-queue / processing rules.
12
+ - **TheMQ Ack** acknowledges a trigger-delivered message.
13
+
14
+ ## Requirements
15
+
16
+ - n8n with community nodes available.
17
+ - TheMQ **3.0.0 or newer**, reachable from n8n.
18
+ - A TheMQ API token.
8
19
 
9
20
  ## Install
10
21
 
11
- In n8n: **Settings → Community Nodes → Install** → `n8n-nodes-themq`.
12
- Or `npm install n8n-nodes-themq` in `~/.n8n`, then restart n8n.
22
+ ### From the n8n UI
13
23
 
14
- Add a **TheMQ API** credential: the TheMQ **Base URL**
15
- (e.g. `http://themq:3000`) and the **API Token** — the `API_TOKEN` value
16
- pinned in `docker-compose.yml` (overridable via environment).
24
+ 1. Open **Settings → Community Nodes**.
25
+ 2. Select **Install**.
26
+ 3. Enter `n8n-nodes-themq` and confirm.
27
+ 4. Restart n8n if your installation requires it.
17
28
 
18
- ## TheMQ Trigger
29
+ ### From npm
19
30
 
20
- Listens to a TheMQ queue **over a persistent consumer connection** —
21
- every message starts an execution immediately. There is no polling
22
- interval; deactivating the workflow closes the connection and pending
23
- messages are requeued for redelivery.
31
+ ```bash
32
+ cd ~/.n8n
33
+ npm install n8n-nodes-themq
34
+ # restart n8n
35
+ ```
24
36
 
25
- ```text
26
- Credentials
27
- Queue
37
+ ### Add the credential
38
+
39
+ Create a **TheMQ API** credential:
28
40
 
29
- Options
30
- + Acknowledge
31
- + Max Concurrent Executions
41
+ | Field | Value |
42
+ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
43
+ | **Base URL** | `http://localhost:3000` (or your configured `API_PORT`) when n8n runs on the host; `http://themq:3000` when n8n shares TheMQ's Docker network |
44
+ | **API Token** | The `API_TOKEN` configured on TheMQ |
45
+
46
+ If `API_TOKEN` is unset, TheMQ generates one on first start and persists it in
47
+ Redis. Fetch it with `redis-cli GET <REDIS_KEY_PREFIX>:auth:api-token` (the
48
+ default prefix is `themq`).
49
+
50
+ ## Quick start
51
+
52
+ 1. Add a **TheMQ Trigger** and select the credential.
53
+ 2. Enter the queue to listen to.
54
+ 3. Under **Options**, set **Acknowledge** to **Execution Finishes Successfully**
55
+ for retry-on-failure, or choose another mode below.
56
+ 4. Add your processing nodes.
57
+ 5. To control acknowledgement manually, choose **Specified Later in Workflow**
58
+ and add **TheMQ Ack** where the work is done.
59
+
60
+ ```text
61
+ TheMQ Trigger (Specified Later in Workflow)
62
+ ↓
63
+ Process
64
+ ↓
65
+ TheMQ Ack
32
66
  ```
33
67
 
34
- ### Acknowledge
35
-
36
- Every delivered message is leased, not given away: it must be
37
- acknowledged, or it comes back. There is **no deadline** — like a
38
- RabbitMQ manual-ack consumer, the broker holds the message however
39
- long the workflow takes. When the acknowledgement happens depends
40
- on this mode:
41
-
42
- - **Immediately** — acknowledged as soon as it arrives, with no
43
- concurrency limit (RabbitMQ auto-ack). The workflow still runs, but a later failure can no
44
- longer return the message. Use it when losing a message on failure is
45
- acceptable.
46
- - **Execution Finishes** — acknowledged when the execution finishes,
47
- however long that takes, whether it succeeded or not.
48
- - **Execution Finishes Successfully** — acknowledged only on success, however
49
- long that takes. On failure the message goes back to the queue and is
50
- delivered again (with `redelivered: true` and a higher `deliveryCount`).
51
- - **Specified Later in Workflow** — the trigger does not settle. Add a
52
- **TheMQ → Acknowledge** node where the message is truly done; its
53
- fields pick up the trigger item automatically. The message stays held
54
- without a deadline until then. If the run ends without
55
- acknowledgement, success acknowledges and failure returns the message.
56
-
57
- Whichever mode you pick, a dropped connection returns its pending
58
- messages immediately for redelivery. If the connection drops while the
59
- workflow is active (TheMQ restart, deploy, network blip), the trigger
60
- reconnects on its own with backoff instead of failing — only
61
- misconfiguration (bad credentials, deleted queue, protocol errors)
62
- deactivates it with an error. Delivery is at-least-once:
63
- keep your workflow idempotent if duplicates would hurt.
68
+ The default mode is **Immediately** (acknowledged on arrival). For most
69
+ workflows that need retries, use **Execution Finishes Successfully**.
64
70
 
65
- ### Max Concurrent Executions
71
+ ## TheMQ Trigger
72
+
73
+ The trigger listens to a queue **over a persistent consumer connection** —
74
+ every message starts an execution immediately. There is no polling interval;
75
+ deactivating the workflow closes the connection and pending messages are
76
+ requeued for redelivery.
77
+
78
+ | Setting | What it does |
79
+ | ----------------------------- | -------------------------------------------------------------------- |
80
+ | **Queue** | The queue to listen to. Declared automatically if it does not exist. |
81
+ | **Acknowledge** | When messages are acknowledged (see the modes below). |
82
+ | **Max Concurrent Executions** | How many messages this trigger holds at once (default `1`). |
83
+
84
+ ### Acknowledge modes
85
+
86
+ Every delivered message is leased, not given away: it must be acknowledged,
87
+ or it comes back. There is **no deadline** — like a RabbitMQ manual-ack
88
+ consumer, the broker holds the message however long the workflow takes. When
89
+ the acknowledgement happens depends on this mode:
66
90
 
67
- At most this many messages being processed at the same time (default
68
- `1`). The broker leases no more than this many unacknowledged messages
69
- to the trigger, so further messages simply wait in the queue until one
70
- is acknowledged. The option is hidden while Acknowledge is
71
- `Immediately` — with nothing ever left unacknowledged there is nothing
72
- to cap, so that mode flows without a limit. Raise the limit when your
73
- workflow can safely run in parallel.
91
+ | Mode | Acknowledged when | If the execution fails |
92
+ | ----------------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------- |
93
+ | **Immediately** | As soon as the message arrives | The message is already acknowledged, so the failure cannot return it. |
94
+ | **Execution Finishes** | The execution ends, whether it succeeded or failed | Already acknowledged; the failure cannot return it. |
95
+ | **Execution Finishes Successfully** | The execution succeeds | The message returns to the queue and is delivered again. |
96
+ | **Specified Later in Workflow** | A **TheMQ Ack** node runs | If the run ends without an ack: success acknowledges, failure returns it. |
74
97
 
75
- A message that keeps failing will keep coming back. To stop the loop,
76
- check `deliveryCount` with an IF node and route poison messages to an
77
- **TheMQ → Acknowledge** node — acknowledging removes them for good.
78
- (The **Delete Message** operation is for messages still waiting in the
79
- queue, not for ones already delivered.)
98
+ **Immediately** has no concurrency limit (RabbitMQ auto-ack), so **Max
99
+ Concurrent Executions** is hidden in that mode.
100
+
101
+ Whichever mode you pick, a dropped connection returns its pending messages
102
+ immediately for redelivery. If the connection drops while the workflow is
103
+ active (TheMQ restart, deploy, network blip), the trigger reconnects on its
104
+ own with backoff instead of failing — only misconfiguration (bad credentials,
105
+ deleted queue, protocol errors) deactivates it with an error.
106
+
107
+ Delivery is at-least-once: keep your workflow idempotent if duplicates would
108
+ hurt.
109
+
110
+ ### Max Concurrent Executions
111
+
112
+ At most this many messages being processed at the same time (default `1`).
113
+ The broker leases no more than this many unacknowledged messages to the
114
+ trigger, so further messages wait in the queue until one is acknowledged. Raise
115
+ the limit when your workflow can safely run in parallel.
80
116
 
81
117
  ### Output item
82
118
 
@@ -91,94 +127,120 @@ queue, not for ones already delivered.)
91
127
  }
92
128
  ```
93
129
 
130
+ - `queue` and `messageId` identify the message.
131
+ - `consumerId` is this trigger's consumer.
132
+ - `data` is the published payload.
133
+ - `deliveryCount` counts deliveries; `redelivered` is `true` on retries.
134
+
135
+ ### Handling failures
136
+
137
+ A message that keeps failing will keep coming back. To stop the loop, check
138
+ `deliveryCount` with an IF node and route poison messages to a
139
+ **TheMQ Ack** node — acknowledging removes them for good.
140
+
94
141
  ### Troubleshooting
95
142
 
96
- **"Timed out waiting for a TheMQ hello reply" on activation.**
97
- The trigger opened the connection but the server never answered. Check,
98
- in order:
143
+ #### "Timed out waiting for a TheMQ hello reply" on activation
144
+
145
+ The trigger opened the connection but the server never answered. Check, in
146
+ order:
99
147
 
100
- 1. TheMQ is **3.0.0+** and reachable from n8n:
148
+ 1. TheMQ is reachable from n8n and is version **3.0.0+**. Try
101
149
  `docker compose pull && docker compose up -d`, then
102
150
  `curl http://<host>:3000/health/ready`.
103
- 2. Redis is healthy (`/health/ready` returns 200, not 503).
104
- 3. The TheMQ logs around activation (`docker compose logs themq`):
151
+ 2. Redis is healthy (`/health/ready` returns `200`, not `503`).
152
+ 3. TheMQ logs around activation (`docker compose logs themq`):
105
153
  `Consumer connected` means the hello succeeded; `subscribe-failed` /
106
154
  `frame-failed` entries explain the refusal.
107
155
 
108
- **Node shows "TheMQ is not reachable".** The Base URL in your credential
109
- is wrong or TheMQ is down. Verify with
156
+ #### TheMQ is not reachable
157
+
158
+ The Base URL in your credential is wrong, or TheMQ is down. Verify with
110
159
  `curl http://<host>:3000/health/live` from the n8n host.
111
160
 
112
- **"UNAUTHENTICATED".** The API Token in your credential is wrong or stale.
113
- Fetch the current one from Redis or pin `API_TOKEN`.
161
+ #### UNAUTHENTICATED
114
162
 
115
- ## TheMQ node
163
+ The API Token in your credential is wrong or stale. Fetch the current one from
164
+ Redis or pin `API_TOKEN`.
116
165
 
117
- Exactly four operations — nothing else:
166
+ ## Upgrading
118
167
 
119
- ```text
120
- Publish · Acknowledge · Requeue · Delete Message
121
- ```
168
+ The package keeps the existing node types (`theMq`, `theMqTrigger`, and the new
169
+ `theMqAck`). Existing workflows do not need to be removed and re-added.
170
+ Existing `theMq` nodes stay on version 1; after updating the package, use
171
+ n8n's node-version control to move to version 2 when you want the simplified
172
+ Publish settings. Version 1 `publish`, `ack`, `requeue`, and `delete` workflows
173
+ continue to run. The TheMQ server API remains backward compatible; the optional
174
+ `PUT .../messages/:id/data` endpoint is additive.
122
175
 
123
- - **Publish** — Queue, Message ID (required; the upsert key), Message
124
- Data, Upsert flag (update the ID in place instead of conflicting),
125
- On Conflict (Error, or Skip to return the existing message's state with
126
- `skipped: true` instead of failing — works for queued and leased
127
- messages), Delay (wait before the message becomes available).
128
- - **Acknowledge** — marks a trigger-delivered message as successfully
129
- processed. Queue and Message ID default to the trigger item, so no
130
- wiring is needed.
131
- - **Requeue** — ensures a message ends up queued, whatever state it is
132
- in. Leased messages (picked up but unacked) are requeued; messages
133
- still waiting are left in place (or updated when Options carry new
134
- terms); missing messages are published (needs Message Data in
135
- Options, or a trigger item carrying the payload). Queue and Message
136
- ID default to the trigger item; the optional Options (+) take a
137
- replacement Message Data and a Delay before it becomes available
138
- again. Empty options requeue with the original details.
139
- - **Delete Message** — removes a waiting message so it is never
140
- processed. Queue and Message ID default to the trigger item.
176
+ ## TheMQ Publish
141
177
 
142
- ```text
143
- TheMQ Trigger (Specified Later in Workflow)
144
- ↓
145
- Process
146
- ↓
147
- TheMQ → Acknowledge
148
- ```
178
+ Clean fields first:
149
179
 
150
- Or automatic:
180
+ 1. **Queue**
181
+ 2. **Message ID**
182
+ 3. **Message Data**
183
+ 4. **Delay (Ms)**
151
184
 
152
- ```text
153
- TheMQ Trigger (Execution Finishes Successfully)
154
- ↓
155
- Process
156
- ```
185
+ Then choose exactly what happens in each case.
186
+
187
+ ### If the message does not exist
188
+
189
+ `not_exist` → **Publish it**. The four fields above are used.
190
+
191
+ ### If the message is on queue
192
+
193
+ `on_queue` means the message is waiting (`ready` or `delayed`). Choose any:
194
+
195
+ - **skip** — do nothing.
196
+ - **update_msg** — update message data with **Message Data**.
197
+ - **update_ttl** — reset TTL to **Delay (Ms)**, counting from now.
198
+ - **update_all** — update both message data and TTL.
199
+
200
+ ### If the message is processing
201
+
202
+ `processing` means the message is leased (`unacked`). Choose one:
203
+
204
+ - **skip** — do nothing.
205
+ - **requeue** — acknowledge the current lease and put it back on queue with
206
+ **Message Data** and **Delay (Ms)**.
207
+ - **ack** — acknowledge the current message.
208
+
209
+ Under **requeue**, **Stop its execution** cancels the processing n8n execution
210
+ after the message is requeued. Use it when a newer message replaces work that
211
+ is already running.
212
+
213
+ ## TheMQ Ack
214
+
215
+ Simple acknowledgement node for a trigger-delivered message. **Queue** and
216
+ **Message ID** default to the trigger item. It marks the message successfully
217
+ processed and resolves a waiting trigger.
157
218
 
158
219
  ## Examples
159
220
 
160
- Publish from any workflow (Message ID is required — it is the upsert key;
161
- tick **Upsert** to update an existing ID instead of conflicting):
221
+ ### Publish on a schedule
162
222
 
163
223
  ```text
164
- Schedule Trigger → TheMQ (Publish: queue "orders", id "order-42", data {...})
224
+ Schedule Trigger → TheMQ Publish (queue "orders", id "order-42", data {...})
165
225
  ```
166
226
 
167
- Competing workers — two activated workflows with triggers on the same
168
- queue each get different messages, FIFO.
227
+ The Message ID is required. Use **If the message is on queue → update_msg**
228
+ or **update_all** to update an existing waiting message.
169
229
 
170
- Drop a queued message before it is ever delivered:
230
+ ### Run competing workers
171
231
 
172
- ```text
173
- TheMQ → Delete Message
174
- ```
232
+ Activate two workflows with **TheMQ Triggers** on the same queue. Each trigger
233
+ gets different messages, in FIFO order.
175
234
 
176
- Send a delivered message back with new data, a delay, or both:
235
+ ### Requeue a delivered message
177
236
 
178
237
  ```text
179
- TheMQ → Requeue
238
+ TheMQ Publish (processing: requeue)
180
239
  ```
181
240
 
241
+ Set **Message Data** and **Delay (Ms)** for the new details. Optionally enable
242
+ **Stop its execution**.
243
+
182
244
  ## Development
183
245
 
184
246
  ```bash
@@ -186,9 +248,12 @@ npm install
186
248
  npm run typecheck
187
249
  npm run lint
188
250
  npm run format
251
+ npm run test
189
252
  npm run build # tsc -> dist/ (+ icons)
190
253
  ```
191
254
 
255
+ `npm test` builds `dist/` and runs the unit tests.
256
+
192
257
  ## License
193
258
 
194
- ISC — see [LICENSE](../LICENSE).
259
+ ISC — see [LICENSE](LICENSE).
@@ -1,20 +1,3 @@
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
- /** Strip trailing slashes so `baseUrl + path` never doubles them. */
7
- export declare function normalizeBaseUrl(baseUrl: string): string;
8
- export interface RequestContext {
9
- itemIndex: number;
10
- operation: string;
11
- queue?: string;
12
- messageId?: string;
13
- baseUrl?: string;
14
- }
15
- export declare function describeApiError(error: unknown, context: {
16
- operation: string;
17
- queue?: string;
18
- messageId?: string;
19
- baseUrl?: string;
20
- }): string;
1
+ import { VersionedNodeType } from "n8n-workflow";
2
+ /** Keep old workflows on version 1; new nodes use the simplified version 2. */
3
+ export declare const TheMq: VersionedNodeType;