subscribe abstract method

Future<BrokerSubscription> subscribe(
  1. String topic, {
  2. required String group,
  3. required MessageHandler onMessage,
})

Receives messages from topic, calling onMessage for each.

group names a set of consumers that share the work: every message goes to exactly one member. Two different groups on the same topic each get their own copy, which is how several services react to one event without the publisher knowing about any of them.

A handler that throws does not acknowledge, leaving the message for redelivery.

Implementation

Future<BrokerSubscription> subscribe(
  String topic, {
  required String group,
  required MessageHandler onMessage,
});