I am currently using Redis version 2.6.12 and 2.4.5 for windows port version for some performance analysis. I have written a pub/sub application which I have a window service acting as a subscriber. and another windows form acting as Publisher.
I have noticed that after sending around 50++ consecutive messages from the publisher. The subscriber stops responding to new messages. There is no exception thrown from the publisher side.
Same behaviour occurred on both version of Redis.
Has anyone experienced this kind of weird behaviour?
This is the code from my windows form (publisher):
using (var redisPublisher = new RedisClient())
{
var message = new LastTrainProcessedMessage(DateTime.Now, "TEST", SystemMonitorStatus.Normal, 10);
label1.Text += (String.Format(@"Publishing '{0}' to '{1}'", message.ToString(), ChannelName)) + Environment.NewLine;
redisPublisher.PublishMessage(ChannelName, ServiceStack.Text.JsonSerializer.SerializeToString(message, typeof(LastTrainProcessedMessage)));
}
This is the code from my Subscriber:
using (_redisConsumer = new RedisClient("localhost"))
using (_subscription = _redisConsumer.CreateSubscription())
{
try
{
_subscription.OnSubscribe = channel => _logger.Info(string.Format("Subscribed to '{0}'", channel));
_subscription.OnUnSubscribe = channel => _logger.Info(string.Format("UnSubscribed from '{0}'", channel));
_subscription.OnMessage = (channel, msg) =>
{
_logger.Info(string.Format("Received '{0}' from channel '{1}'", msg, channel));
var ltpm = JsonSerializer.DeserializeFromString<LastTrainProcessedMessage>(msg);
//persist to redis and trigger SignalR call...
_smState.UpdateLastTrainProcessedState(ltpm.ReadingTimestamp, ltpm.Location, SystemMonitorStatus.Normal);
_smState.AddAlerts(ltpm.NumberOfAlerts);
};
_logger.Info(string.Format("Started Listening On '{0}'", _channelName));
_subscription.SubscribeToChannels(_channelName); //blocking
}
catch (Exception ex)
{
_logger.Error(ex);
}
}
Thanks.