Skip to main content

Message Queue Isolation

Message queues introduce asynchronous communication between microservices, typically via a message queue broker or service. Since communication is indirect, one might consider including the broker and producers in sandboxes when working on a message queue consumer microservice, to ensure the sandbox consumer does not interfere with the baseline by consuming messages intended for the baseline.

However, this is often impractical in terms of setup time and resource usage. Signadot provides more effective alternatives for isolating message queue traffic in sandboxes.

Set this up with a coding agent​

A coding agent can find the producers and consumers in your code, pick an isolation pattern from this page and your broker's page, and adapt the matching example from the examples repository to your services. It writes the code and config changes as diffs, with the order to roll them out in. It follows the rules for agents: read-only checks first, then a plan you approve, then files you apply.

Prompt: isolate message queue traffic
Goal: Let a sandboxed consumer handle only the messages its sandbox's
requests produce, while the baseline keeps handling the rest, on the brokers
we already share. Plan the code and config changes; stop before anything is
merged or deployed.

Rules:
- Work on a branch. Show me each code or config change as a diff before you
commit it, and don't merge anything.
- Confirm the kube context with me before running any kubectl command, use a
non-production cluster such as staging, and run only read-only kubectl
commands.
- You may create and delete sandboxes, only on the cluster I confirmed.
- Don't fork a consumer until the baseline consumer change is deployed and I
say so; until then a forked consumer can take the baseline's messages.
- If you pick a topic or queue per sandbox, write the resource plugin but
don't create it in Signadot; I review it first.

Read:
- https://www.signadot.com/docs/guides/set-up-message-queue-isolation.md, then
the page for each broker we use:
https://www.signadot.com/docs/guides/set-up-message-queue-isolation/kafka.md
https://www.signadot.com/docs/guides/set-up-message-queue-isolation/rabbitmq.md
https://www.signadot.com/docs/guides/set-up-message-queue-isolation/sqs.md
https://www.signadot.com/docs/guides/set-up-message-queue-isolation/pubsub.md
https://www.signadot.com/docs/guides/set-up-message-queue-isolation/redis-streams.md
https://www.signadot.com/docs/guides/set-up-message-queue-isolation/nats.md
- https://www.signadot.com/docs/tutorials/messaging-and-workflows.md for
Temporal, Sidekiq, Dapr and Debezium.
- https://www.signadot.com/docs/guides/set-up-context-propagation.md, because
producers have to carry the routing key into each message.
- The example that matches our stack:
Kafka: https://github.com/signadot/examples/tree/main/selective-consumption-with-kafka
RabbitMQ: https://github.com/signadot/examples/tree/main/rabbitmq-signadot-demo
SQS and SNS: https://github.com/signadot/examples/tree/main/SQS-Based-Microservices-with-Signadot-main
Pub/Sub: https://github.com/signadot/examples/tree/main/selective-consumption-with-google-pub-sub
Redis Streams: https://github.com/signadot/examples/tree/main/selective-consumption-with-redis-streams
Temporal: https://github.com/signadot/examples/tree/main/temporal-tutorial
Sidekiq: https://github.com/signadot/examples/tree/main/sidekiq-tutorial
Dapr: https://github.com/signadot/examples/tree/main/dapr-tutorial
Debezium: https://github.com/signadot/examples/tree/main/debezium-cdc-tutorial
There is no NATS example; follow the NATS page instead.
If a page doesn't load, stop and tell me.

Discover (read-only):
1. Ask me which consumer services we want to fork first.
2. For each producer and consumer of the topics or queues those services
use, list the broker, client library and version, topic, queue, stream or
subscription names, consumer group or subscription names, where each name
comes from (code, config, environment), and how messages are built
(headers or attributes).
3. Check whether producers already put the routing key into each message:
the baggage header or attribute, set by tracing instrumentation or by
hand.

Decide:
- The pattern, from the approaches on the overview and broker pages:
message-level routing (both sandbox and baseline check each message's
routing key against the Routes API and handle only their own) or a topic
or queue per sandbox (a resource plugin, with every producer on that topic
forked too). Default to message-level routing unless we can't change the
consumer code.
- For message-level routing, how each consumer gets messages, from its
broker page: its own consumer group, subscription or queue, so it gets a
copy of every message (Kafka, RabbitMQ, Pub/Sub, Redis Streams, or an SQS
queue per consumer behind SNS), or one shared queue the consumers compete
for (a single SQS queue).
- Which example to adapt, and whether the change belongs in a shared library
rather than in each service.

Produce:
- Producer diffs that put baggage into message headers or attributes, where
instrumentation doesn't already.
- Consumer diffs: the sandboxed consumer processes only messages for its
sandbox; the baseline consumer skips messages whose routing key belongs to
a live sandbox of the same workload. For a message it skips, a consumer
with its own copy acknowledges it where the broker needs that (or deletes
it, on an SQS queue of its own); a consumer on a shared SQS queue never
deletes it, and calls ChangeMessageVisibility with VisibilityTimeout=0 so
another consumer can take it.
- Environment and config diffs, and a sandbox spec that forks one consumer
for testing.
- Rollout order: the baseline consumer change ships and is running before
any sandboxed consumer starts, or the baseline also processes sandbox
messages.

Stop and report: the pattern and why, the diffs, the rollout order, and open
questions.

General Approaches to Message Queue Isolation​

1. Message-Level Routing (Routing API)​

Many message queues (e.g., Kafka) support multiple consumers. In these scenarios, each consumer can receive all messages. To isolate sandboxes, you can:

  1. Decorate messages with a routing key in the header or message attribute.
  2. Send all messages to all consumers (e.g., Kafka consumer groups).
  3. Configure each consumer to process or ignore messages based on the routing key.

With message-level routing, the baseline consumer must also skip messages whose routing key belongs to a live sandbox of the same workload; otherwise the baseline and the sandbox both process them. Ship that baseline change before any sandboxed consumer starts. The Kafka page shows how both sides check each message.

This approach is lightweight, flexible, and works with RouteGroups. It allows sharing the message queue broker between the baseline and sandboxes without interference.

Signadot provides gRPC and REST APIs, and library code to support this methodology. See this working demo, and the Redis Streams tutorial for the same pattern on Redis consumer groups in Python. For job queues that give each job to exactly one worker, the Sidekiq tutorial has the baseline worker hand jobs to a queue per sandbox. The same approach extends to durable-execution engines: the Temporal worker tutorial applies it to Temporal task queues in Python, TypeScript, Go, and Java.

2. Topic/Queue-Based Isolation​

Alternatively, use ResourcePlugins to create dedicated topics or queues for each sandbox. This requires only topic/queue name configuration for producers and consumers, but is less flexible than message-level routing.


System-Specific Integrations​

For detailed guidance on implementing message queue isolation with specific systems, see the following pages: