Observable stream from StackExchange Redis Pub Sub subscription
<p><strong>OBJECTIVE:</strong></p>

<p>I am using StackExchange Redis Client. My objective is to create an Observable stream from the Pub Sub Subscriber exposed by the Client, that can then in turn support <em>1-n</em> subscriptions by Observables, that each have their own filter via LINQ. (Publishing is working as planned, the issue is purely around Subscription to the Event Stream on a specific channel.)</p>

<p><strong>BACKGROUND:</strong></p>

<p>I am using Redis Pub Sub as part of an Event Sourced CQRS application. The specific use case is to publish Events to multiple subscribers that then update the various Read Models, send emails etc.</p>

<p>Each of these Subscribers need to filter the Event Types that they handle, and for this I am looking to use Rx .Net (Reactive Extensions), with LINQ, to
provide a filter criteria on the Event Stream, to efficiently handle reacting only to Events of interest. Using this approach removes the need for registering Handlers with an event bus implementation, and allows me to add new projections to the system by deploying <em>1-n</em> Microservices that each have <em>1-n</em> Observables subscribed to the Event Stream with their own specific filters.</p>

<p><strong>WHAT I HAVE TRIED:</strong> </p>

<p>1) I have created a class inheriting from ObservableBase, overriding the SubscribeCore method, which receives subscription requests from Observables, stores them in a ConcurrentDictionary, and as each Redis notification arrives from the channel, loops through the registered Observable subscribers and calls their OnNext method passing the RedisValue. </p>

<p>2) I have created a Subject, that also accepts subscriptions from Observables, and calls their OnNext method. Again, the use of Subjects appears to be frowned upon by many.</p>

<p><strong>THE ISSUE:</strong></p>

<p>The approaches I have tried do function (at least superficially), with varying levels of performance, but <code>feel like a hack</code>, and that I am not using Rx in the way it was intended.</p>

<p>I see many comments that the built-in Observable methods should be used where at all possible, for example Observable.FromEvent, but that seems to be impossible to do with the StackExchange Redis Clients Subscription API, at least to my eyes.</p>

<p>I also understand that the preferred method for receiving a stream and forwarding to <em>multiple</em> Observers is to use a <strong>ConnectableObservable</strong>, which would seem to be designed for the very scenario I face (Each Microservice will internally have <em>1-n</em> Observables subscribed). At the moment, I cannot get my head around how to connect a <strong>ConnectableObservable</strong> to the notifications from StackExchange Redis, or if it offers real benefit over an <strong>Observable</strong>.</p>

<p><strong>UPDATE</strong>:</p>

<p>Although completion is not an issue in my scenario (Disposal is fine), error handling <em>is</em> important; e.g. isolating errors detected in one subscriber to prevent all subscriptions terminating. </p>