private static void ReceiveInputFromAirlineSAS(MessageQueue inputChannel, MessageQueue outputQueue) { inputChannel.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) }); inputChannel.ReceiveCompleted += ((object source, ReceiveCompletedEventArgs asyncResult) => { MessageQueue messageQueue = (MessageQueue)source; var message = messageQueue.EndReceive(asyncResult.AsyncResult); var location = (string)message.Body; Console.WriteLine("Received query from Airline SAS: " + location); var reply = WeatherCondition.GenerateWeatherConditionAirlineCompany(weatherManager.GetCurrentWeatherCondition(location)); Console.WriteLine("Responding with object:"); Console.WriteLine(reply); outputQueue.Send(reply, location); messageQueue.BeginReceive(); }); inputChannel.BeginReceive(); }
private static void ReceiveInputFromAirlineBritishAirways(MessageQueue inputChannel, MessageQueue outputQueue) { inputChannel.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) }); inputChannel.ReceiveCompleted += ((object source, ReceiveCompletedEventArgs asyncResult) => { MessageQueue messageQueue = (MessageQueue)source; var message = messageQueue.EndReceive(asyncResult.AsyncResult); var location = (string)message.Body; Console.WriteLine("Received query from Airline British Airways: " + location); var weather = WeatherCondition.GenerateWeatherConditionAirlineCompany(weatherManager.GetCurrentWeatherCondition(location)); var weatherFeed = XmlHelper.Serialize <WeatherConditionAirlineCompany>(weather); var reply = XmlHelper.GenerateDocumentFromFeed(weatherFeed); Console.WriteLine("Responding with XmlDocument:"); Console.WriteLine(reply + " with the content:"); Console.WriteLine(reply.OuterXml); outputQueue.Send(reply, location); messageQueue.BeginReceive(); }); inputChannel.BeginReceive(); }