A Simple Orleans Implicit Stream Example
While exploring Microsoft Orleans for potential use in developing a CQRS & Event Sourced application, I was delighted to see Implicit Streams being supported as a method for propagating Events to Grains. Unfortunately, at the time of this writing, the documentation is a little lacking in how to properly setup Implicit Streaming. Fortunately, there are official samples that cover most use cases, including Implicit Streaming, but those require using Event Hubs, which is hardly a “download & run” scenario. As such, I have provided a completely barebones sample to demonstrate how Implicit Streaming is setup. https://github.com/jsedlak/orleans-samples/tree/main/Streaming/ImplicitStreams The solution contains three projects: A Shared Library containing all the common code, an Orleans Client, and an Orleans Host. Here are the key points to know. We create a few constants to ensure we’re always referencing the correct stream. In our Silo configuration, we’re going to add Memory Streams with our custom Provider Name, and inform the framework that this provider will be Implicit Only, allowing us to proceed without a PubSubStore. Our Producer Grain is going to create the Stream and register a Grain Timer to introduce stream data every N=1 seconds. It is also worth noting the sample uses 8.2.0, which utilizes the new RegisterGrainTimer method. We expose this as a Grain Method in the IProducerGrain interface to ensure the Client can control when stream data starts producing. On every tick of the timer, we simply increment a count and send it to the Stream using OnNextAsync. What is not clear