private void ResponseCallback(RedisChannel chl, RedisValue msg) { PubSubResponseMessage response = JsonConvert.DeserializeObject <PubSubResponseMessage>(msg); _messageCallbacks.TryGetValue(response.CorrelationId, out Action <PubSubResponseMessage> waitingCallback); waitingCallback?.Invoke(response); }
private void RequestCallback(RedisChannel chl, RedisValue msg) { PubSubRequestMessage requestMessage = JsonConvert.DeserializeObject <PubSubRequestMessage>(msg); Thread.Sleep(100 + new Random().Next(500, 2000)); PubSubResponseMessage responseMessage = new PubSubResponseMessage() { CorrelationId = requestMessage.CorrelationId, ResponseValue = $"Hello {requestMessage.Value}" }; string message = JsonConvert.SerializeObject(responseMessage); _subscriber.Publish(requestMessage.ResponseChannel, message); }