InMemoryBroker class

A broker that keeps everything in this process.

For tests and for running a system locally without standing up real infrastructure. It models the parts of broker behaviour that change how code must be written — consumer groups sharing work, separate groups each getting a copy, and redelivery when a handler throws — and none of the parts that make a real broker useful: nothing survives a restart, and nothing crosses a process boundary.

Implemented types

Constructors

InMemoryBroker({bool redeliver = true})

Properties

hashCode int
The hash code for this object.
no setterinherited
published List<BrokerMessage>
Every message accepted, in order. For assertions in tests.
final
redeliver bool
Whether a message whose handler threw is offered again.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() Future<void>
override
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.
override
subscribe(String topic, {required String group, required MessageHandler onMessage}) Future<BrokerSubscription>
Receives messages from topic, calling onMessage for each.
override
toString() String
A string representation of this object.
inherited

Operators

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