MessageBroker class abstract interface

A message broker this service publishes to and consumes from.

Revali does not run a broker. Like a database, the broker is infrastructure you deploy; this is the client side of it. Implementations live in their own packages so the framework never has to pick a winner between brokers whose delivery and ordering guarantees genuinely differ.

Handlers must be idempotent. Every broker worth using delivers at least once, which means a message that was handled but whose acknowledgement was lost will arrive again. That is not a bug to be engineered away at this layer — it is the contract.

Implementing one

If the broker identifies this client to the server by name — a Redis Streams consumer, a Kafka group.instance.id, a NATS durable — run that name through IsolateIdentity.scopeName before sending it. createBroker runs in every isolate of an app with AppConfig.workers above 1, so a name passed through untouched makes every worker claim to be the same client. On a broker that tracks unacknowledged work per client that is not a cosmetic collision: each worker's pending messages become invisible to the others, and the app looks healthy while work sits unretried.

The framework cannot do this for you. It never sees the name — the implementation builds it — so this is an obligation of the implementation, and the reason IsolateIdentity.scopeName is public.

Implementers

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() Future<void>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
publish(String topic, String payload, {Map<String, String> headers = const {}}) Future<void>
Sends payload to topic.
subscribe(String topic, {required String group, required MessageHandler onMessage}) Future<BrokerSubscription>
Receives messages from topic, calling onMessage for each.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited