So I was off for a week, then got elbow deep on one of the projects. Slowly recovering to normal work rhythm. Until the work I am doing is completed – expected by end of October, stay tuned for future announcements 🙂 – I thought I’d share something of interest.
I am working with a Service Fabric service, where each service is expected to have:
- 0..n number of event hubs listeners. The event hub number can change as in add, remove hubs etc. Needless to say the service doesn’t need to stop, start, reset or upgrade in case of event hub
- 1 – Only one – REST control endpoint, where you can interact with the service to do:
- Add Hubs.
- Remove Hubs.
- Get # of processed messages and other relevant telemetry data.
- Stop/Start/Pause processing.
Service Fabric allows you to create one listener per service (for purest folks, per replica). More details here (http://henidak.com/2015/07/service-fabric-partitions/). In order to allow this to happen I created a composite listener, basically sets on top a list of listeners, listeners can be added, removed without affecting service lifecycles. The composite listener ensure that newly added listeners status matches the composite listener. As in if the composite listener has been opened-async then the newly added listeners will be opened-async-ed as well.
The composite listener can work with any class that implements ICommunicationListener interface (including those provided in the public samples).
I published it as a gist on github here: https://gist.github.com/khenidak/21f8de349a460ab90408
Till next time @khnidk