method InMemoryBroker.prototype.publish
Since 0.1.0
InMemoryBroker.prototype.publish<T>(
topic: string,
message: T
): Promise<void>

Publishes a message to a topic.

Delivers to all subscribers without a queue (fanout), and to one subscriber per queue (round-robin load balancing).

Type Parameters

The message payload type

Parameters

topic: string

The topic to publish to

message: T

The message payload

Return Type

Promise<void>

Resolves once every matching subscription's work item has been handed to dispatch — NOT once every handler has returned. A handler's rejection reaches the configured onDispatchError (or is observed and dropped when none is configured); it never rejects the publish and never becomes an unhandled rejection. This is the guarantee real brokers give — publish returns before delivery — so the in-memory double honours it too. Since M89c it also means one slow or throwing fan-out handler no longer delays or aborts delivery to its siblings.

Usage

import { InMemoryBroker } from "messaging-plugin/src/index.ts";