message-brokers 1.11.0-beta.2 → 1.11.0-beta.3

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 CHANGED
@@ -55,7 +55,7 @@ RABBITMQ_DEPLOYMENT_ENV=stage
55
55
  #
56
56
  # Example:
57
57
  # base.queue → base.queue.stage
58
- # base-key → base-key.stage
58
+ # base-key → base-key-stage
59
59
  #
60
60
  # Use this when multiple environments (stage/dev/prod) share the same RabbitMQ cluster.
61
61
 
@@ -74,6 +74,7 @@ RABBITMQ_ISOLATED_NAMESPACE=prod-2
74
74
  #
75
75
  # Example:
76
76
  # messaging.queue → messaging.queue.prod-2
77
+ # messaging-key → messaging-key-prod-2
77
78
  #
78
79
  # Purpose:
79
80
  # - Enables tenant-level or client-level isolation within the same broker
@@ -220,6 +221,34 @@ The example output assumes `RABBITMQ_ISOLATED_NAMESPACE=prod-2` and `RABBITMQ_DE
220
221
 
221
222
  The package's `exports` allow only `message-brokers`, `message-brokers/rabbitmq-utils`, `message-brokers/lib/*` and `message-brokers/package.json` to be imported.
222
223
 
224
+ ## Queue isolation
225
+
226
+ Some deployments run two or more servers (stacks) against the same RabbitMQ with the same `RABBITMQ_DEPLOYMENT_ENV`. Each server then sets its own `RABBITMQ_ISOLATED_NAMESPACE` (e.g. `prod-1`, `prod-2`).
227
+
228
+ - **Shared queue (not isolated):** every server binds the same queue and routing key, so a message published by one server can be consumed by any of them. The data flows across servers.
229
+ - **Isolated queue:** each server gets its own queue (`<queue>.<ns>.<env>`) and routing key (`<key>-<ns>-<env>`), so a message stays on the server that published it.
230
+
231
+ Isolation is decided per queue, because one deployment usually needs both kinds. It's configured in `src/configs/mb.configs.js`:
232
+
233
+ - `rabbitmqIsolatedQueues`: queue names. Bindings use these to get the namespace.
234
+ - `rabbitmqIsolatedRoutingKeys`: routing keys. Publishing uses these to get the namespace.
235
+
236
+ An isolated queue must be on **both** lists, otherwise the publish key and the binding key differ and messages are dropped. Both lists are matched by prefix.
237
+
238
+ | Queue | Isolated |
239
+ |---|---|
240
+ | `data-flattening.har.queue` | no |
241
+ | `messaging.har.lab-api.queue` | yes |
242
+ | `datacloak.queue` | no |
243
+ | `raw-queue-processor` | no |
244
+ | `v2.lab-data.queue` | yes |
245
+ | `v2.merged-lab-data.queue` | yes |
246
+ | `billing.events` | yes |
247
+ | `llm-reminder.past-data.queue` | yes |
248
+ | `messaging.past-data.reminder-message.queue` | yes |
249
+
250
+ When you add a queue, decide whether its data may cross servers or must stay on one. Changing the isolation of an existing queue renames it on deployments that set `RABBITMQ_ISOLATED_NAMESPACE`. Upgrade the publisher and the consumers together, then drain and delete the old queue, because the package doesn't remove it.
251
+
223
252
  ## Publish options
224
253
 
225
254
  Every publish method takes an optional last argument `options` (since 1.11.0). Everything is off by default: a call without options behaves as before, except that the message now gets a `message_id`.
@@ -5,8 +5,9 @@ const mbConfigs = {
5
5
  cachingEnabled: process.env.CACHING_ENABLED || false,
6
6
  // Queues that are used in env where multiple instances of same stack share the same rabbitmq.
7
7
  // To avoid messages between different instances, we are isolating the queues.
8
- rabbitmqIsolatedQueues: ["messaging.har.lab-api.queue", "billing.events", "llm-reminder.past-data.queue", "messaging.past-data.reminder-message.queue"],
8
+ rabbitmqIsolatedQueues: ["messaging.har.lab-api.queue", "billing.events", "llm-reminder.past-data.queue", "messaging.past-data.reminder-message.queue", "v2.lab-data.queue", "v2.merged-lab-data.queue"],
9
9
  // Matched by prefix: "past_data." covers past_data.reminder_request and past_data.reminder_message.
10
- rabbitmqIsolatedRoutingKeys: ["har.lab_api_response", "billing", "past_data."]
10
+ // The lab-data keys are listed in full so the plain "lab_api_response" key (datacloak.queue) stays shared.
11
+ rabbitmqIsolatedRoutingKeys: ["har.lab_api_response", "billing", "past_data.", "lab_api_response.amqp", "merged_lab_api_response.amqp"]
11
12
  };
12
13
  module.exports = mbConfigs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "message-brokers",
3
- "version": "1.11.0-beta.2",
3
+ "version": "1.11.0-beta.3",
4
4
  "description": "This package contains functions to publish the messages into the message brokers like rabbitmq.",
5
5
  "main": "lib/message-brokers.js",
6
6
  "types": "lib/types/message-brokers.d.ts",