Created
October 29, 2018 21:02
-
-
Save vainolo/b41dec5ebe0f04e75ca31de255533d79 to your computer and use it in GitHub Desktop.
Taking Azure Redis Cache for a ride – testing a simple Producer/Consumer program - Consumer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
using System.Threading; | |
using Microsoft.WindowsAzure.ServiceRuntime; | |
using StackExchange.Redis;namespace Consumer | |
{ | |
public class WorkerRole : RoleEntryPoint | |
{ | |
public override void Run() | |
{ | |
Trace.TraceInformation("Consumer started"); | |
Subscribe(ConnectionMultiplexer.Connect("")); | |
while (true) | |
{ | |
Thread.Sleep(1000); | |
} | |
} public void Subscribe(ConnectionMultiplexer connection) | |
{ | |
IDatabase cache = connection.GetDatabase(); | |
ISubscriber subscriber = connection.GetSubscriber(); | |
subscriber.Subscribe("ping", (channel, message) => { subscriber.Publish("pong", message); }); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment