PubSub in Service Fabric with Redis

I’ve been working on a project that uses Fabric and I’m hosting Redis inside the cluster as a simple cache system.

One of things that isn’t baked into Fabric is a pub/sub model for communicating between services  about events that are occuring.

As I’ve got the Redis instance up and running in the cluster I decided to take a look at using the Pub/Sub capabilities in Redis to make this happen. N.B Redis isn’t a guarenteed delivery so use where appropriate, there are lots of discussions around it’s pub/sub model and when/where to use etc.

Turns out it’s nice and easy to get working, I’m a big fan of using RX to make nice reactive programs operating on streams of events and there is already a nice sample combineing Redis and RX in C# here.

In not too long I had just what I wanted and through it might be useful to others so I’ve put together a sample. My sample is here with one “EventPublisher” service pushing out events and an “EventSubscriber” listening to events.

Both services write out what they’re up to as ETW messages so you can view in the diagnostic window.

 

image

Lawrence Gripper

@lawrencegripper

Tagged ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: