Choosing a broker
What it is
Section titled “What it is”The broker is the only piece every producer and worker must agree on. gisila_queue ships
three: InMemoryBroker,
RedisBroker and
RabbitBroker. Your task code doesn’t change
between them.
When to use it
Section titled “When to use it”| Situation | Broker |
|---|---|
| Unit and integration tests | InMemoryBroker |
| A single process that wants background work, losing in-flight tasks on crash is fine | InMemoryBroker |
| Production, several processes or hosts | RedisBroker |
| You also want results, dedupe, revoke, beat leader election, events | RedisBroker (everything else is Redis too) |
| You already run RabbitMQ and want its tooling and durability | RabbitBroker (+ Redis for results etc.) |
Default to Redis. With GisilaQueue.redis one
URL gives you broker, results, control channel, beat lock and state, and optional events,
all namespaced.
When not to use it
Section titled “When not to use it”- Don’t use
InMemoryBrokeracross processes or isolates; it is a Dart object. - Don’t point
RedisBrokerat Redis Cluster: its scripts touch keys derived from message contents, which Cluster doesn’t allow across slots. Use a single Redis or a primary with replicas. - Don’t pick RabbitMQ just for durability if you have no RabbitMQ yet; Redis with persistence (AOF) is simpler to run alongside the result backend you need anyway.
How it works
Section titled “How it works”| InMemory | Redis | RabbitMQ | |
|---|---|---|---|
| Delivery | at-most-once | at-least-once | at-least-once |
| Crash recovery | none | visibility timeout (5 min default) | on connection loss |
| Delayed messages | in-process list | sorted set, promoted about every second | TTL delay buckets (100 ms × 2ⁿ) with dead-letter exchange; no plugin |
| Idle workers | poll every 25 ms | BLPOP on notify lists (wake immediately) |
push consumers |
| Queue priority | list order | list order | list order (local inbox) |
| Undecodable payloads | n/a | parked on <prefix>:dead |
rejected (dropped) |
CLI tools (WorkerCli, inspect, rose) |
no | yes | no (build the app by hand) |
inspect unacked count |
n/a | unackedCount() |
RabbitMQ management UI |
The result backend, beat lock and state store, control channel and event transport have
Redis and in-memory implementations only. A RabbitMQ deployment that needs results across
processes uses RedisResultBackend next to RabbitBroker, with the same prefix.
Example
Section titled “Example”import 'package:gisila_queue/gisila_queue.dart';
GisilaQueue buildApp(String env) => switch (env) { 'test' => GisilaQueue(broker: InMemoryBroker(), backend: InMemoryResultBackend()), 'rabbit' => GisilaQueue( broker: RabbitBroker(host: 'rabbit', prefix: 'shop'), backend: RedisResultBackend(host: 'redis', prefix: 'shop'), ), _ => GisilaQueue.redis(namespace: 'shop', host: 'redis'), };