Skip to content

Streaming with Orleans

Orleans streams are typed, logical, multicast channels. Producers and consumers address a stream by provider name and StreamId; they don’t need references to one another. A stream can have many producers and many subscriptions, and every published item is offered to every subscription on that stream.

The stream is a virtual address. Its transport, retention, retry behavior, ordering, and ability to replay are supplied by the configured stream provider. A stream handle alone doesn’t make data durable.

Use streams when events should fan out to independently managed consumers, when subscriptions should outlive a grain activation, or when an external queue or event log should feed grains. For request/response calls, specific connected-client callbacks, or low-overhead best-effort fan-out, another Orleans messaging abstraction can be a better fit. See grain observers for direct client callbacks and Choose an Orleans messaging abstraction for the full decision model.

  • A StreamId consists of a namespace and a key. The provider name selects the configured transport.
  • IAsyncStream<T> is both a producer and consumer handle. Getting a handle is a local operation; publishing and subscribing perform work.
  • Streams are multicast. Multiple producers can publish to one stream, and each active subscription receives each item.
  • Subscriptions can be explicit or implicit.
  • Delivery guarantees, ordering, and replay are provider-specific.
  • Explicit subscription records can be durable only when PubSubStore uses durable grain storage.
  1. Follow the streaming quickstart with the in-memory provider.
  2. Learn stream identity, production, consumption, and subscription APIs.
  3. Choose a provider for the required durability and replay behavior.
  4. Plan for delivery, ordering, replay, and recovery.
  5. Configure PubSub storage and operations for production.

For best-effort implicit fan-out without queueing or replay, see broadcast channels.

For the runtime architecture behind persistent streams, see Orleans streams implementation.