/// <summary> /// Sends the specified message. /// </summary> /// <param name="message">The message.</param> /// <returns>Task.</returns> public void Send(Message message) { using (var client = _pool.Value.GetClient()) { _topic = message.Header.Topic; _logger.Value.DebugFormat("RedisMessageProducer: Preparing to send message"); //Convert the message into something we can put out via Redis i.e. a string var redisMessage = RedisMessagePublisher.EMPTY_MESSAGE; using (var redisMessageFactory = new RedisMessagePublisher()) { redisMessage = redisMessageFactory.Create(message); } _logger.Value.DebugFormat("RedisMessageProducer: Publishing message with topic {0} and id {1} and body: {2}", message.Header.Topic, message.Id.ToString(), message.Body.Value); //increment a counter to get the next message id var nextMsgId = IncrementMessageCounter(client); //store the message, against that id StoreMessage(client, redisMessage, nextMsgId); //If there are subscriber queues, push the message to the subscriber queues var pushedTo = PushToQueues(client, nextMsgId); _logger.Value.DebugFormat("RedisMessageProducer: Published message with topic {0} and id {1} and body: {2} to quues: {3}", message.Header.Topic, message.Id.ToString(), message.Body.Value, string.Join(", ", pushedTo)); } }
/// <summary> /// Creates a plain/text JSON representation of the message /// </summary> /// <param name="message">The Brighter message to convert</param> /// <returns></returns> protected static string CreateRedisMessage(Message message) { //Convert the message into something we can put out via Redis i.e. a string var redisMessage = RedisMessagePublisher.EMPTY_MESSAGE; using (var redisMessageFactory = new RedisMessagePublisher()) { redisMessage = redisMessageFactory.Create(message); } return(redisMessage); }