Skip to content

Commit

Permalink
Optimized RedisMessageBus performance
Browse files Browse the repository at this point in the history
- moved deserialization of RedisMessage out of lock

#2905
  • Loading branch information
alex-simonov committed Mar 4, 2014
1 parent 32c6b49 commit 45652a1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Microsoft.AspNet.SignalR.Redis/RedisMessageBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class RedisMessageBus : ScaleoutMessageBus
private RedisSubscriberConnection _channel;
private int _state;
private readonly object _callbackLock = new object();

[SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "Reviewed")]
public RedisMessageBus(IDependencyResolver resolver, RedisScaleoutConfiguration configuration)
: base(resolver, configuration)
Expand Down Expand Up @@ -142,13 +142,13 @@ private void AttemptReconnect(Exception exception)

private void OnMessage(string key, byte[] data)
{
// The key is the stream id (channel)
var message = RedisMessage.FromBytes(data);

// locked to avoid overlapping calls (even though we have set the mode
// to preserve order on the subscription)
lock (_callbackLock)
{
// The key is the stream id (channel)
var message = RedisMessage.FromBytes(data);

OnReceived(0, message.Id, message.ScaleoutMessage);
}
}
Expand Down

0 comments on commit 45652a1

Please sign in to comment.