public static void Main(string[] args) { Console.Title = "NormalizerJSON"; ConnectionFactory factory = new ConnectionFactory() { HostName = "datdb.cphbusiness.dk", UserName = "******", Password = "******" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.QueueDeclare(); channel.QueueDeclare(queue: QUEUE_NAME, durable: false, exclusive: false, autoDelete: false, arguments: null); Console.WriteLine(" NormalizerJSON ready "); var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var body = ea.Body; var message = Encoding.UTF8.GetString(body); Console.WriteLine(" [x] Received {0}", message); jsonResponse jsonResponse = JsonConvert.DeserializeObject <jsonResponse>(message); string messageToSend = jsonResponse.ssn + "#" + jsonResponse.interestRate; messageToSend = normalizeSsn(messageToSend); BankEngine be = new BankEngine(); try { be.sendMessageCorrelationId(EXCHANGE_NAME, messageToSend, messageToSend, QUEUE_NAME); } catch (Exception e) { e.GetBaseException(); } }; channel.BasicConsume(queue: QUEUE_NAME, autoAck: true, consumer: consumer); Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); } }
static void Main(string[] args) { Console.Title = "NormalizerXML"; ConnectionFactory factory = new ConnectionFactory() { HostName = "datdb.cphbusiness.dk", UserName = "******", Password = "******" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.QueueDeclare(queue: QUEUE_NAME, durable: false, exclusive: false, autoDelete: false, arguments: null); Console.WriteLine(" NormalizerXML ready "); var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var body = ea.Body; var message = Encoding.UTF8.GetString(body); Console.WriteLine(" [x] Received {0}", message); XmlDocument doc = new XmlDocument(); doc.LoadXml(message); XmlNode loanResponseXML = doc.SelectSingleNode("LoanResponse"); string ssn = loanResponseXML["ssn"].InnerText.Insert(6, "-"); double interestRate = XmlConvert.ToDouble(loanResponseXML["interestRate"].InnerText); string messageToSend = ssn + "#" + interestRate; BankEngine be = new BankEngine(); messageToSend = normalizeSsn(messageToSend); be.sendMessageCorrelationId(EXCHANGE_NAME, messageToSend, messageToSend, QUEUE_NAME); }; channel.BasicConsume(queue: QUEUE_NAME, autoAck: true, consumer: consumer); Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); } }
static void Main(string[] args) { Console.Title = "NormalizerMESSAGING"; ConnectionFactory factory = new ConnectionFactory() { HostName = "datdb.cphbusiness.dk", UserName = "******", Password = "******" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.QueueDeclare(queue: QUEUE_NAME, durable: false, exclusive: false, autoDelete: false, arguments: null); var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var body = ea.Body; var message = Encoding.UTF8.GetString(body); Console.WriteLine(" [x] Received {0}", message); BankEngine be = new BankEngine(); be.sendMessageCorrelationId(EXCHANGE_NAME, message, message, QUEUE_NAME); //be.sendMessageReplyAddress(EXCHANGE_NAME, message, message, QUEUE_NAME); }; channel.BasicConsume(queue: QUEUE_NAME, autoAck: true, consumer: consumer); Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); } }