public HttpResponseMessage Post([FromBody] JObject loadTime) { var clientSettings = new MessageBusClient(); var router = clientSettings.GetClientRouter(); var page = new PageModel { Id = Guid.NewGuid().ToString("N"), Key = Guid.NewGuid().ToString("N"), Source = new Dictionary<string, string> { {"Request.ApplicationPath", HttpContext.Current.Request.ApplicationPath}, {"Request.PhysicalApplicationPath", HttpContext.Current.Request.PhysicalApplicationPath}, {"Request.PhysicalPath", HttpContext.Current.Request.PhysicalPath}, }, Metric = new MetricModel { Key = MetricType.LoadTime.ToString(), Value = loadTime.ToString() }, Time = DateTime.UtcNow }; Task.Factory.StartNew(() => { var producerusingClient = new JsonProducer(router); // todo: topics need to be maintained dynamically // todo: we are not specifying the partition producerusingClient.Publish("PageLoadTime", new List<PageModel> { page }); }); return new HttpResponseMessage(HttpStatusCode.Created); }
public static void DisplaySingle(PageModel model) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(string.Format("Reading message with Kafka key => {0} and Redis Id => {1}", model.Key, model.Id)); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("--------------------------------------------------------------------------------------------------------------"); }