예제 #1
0
        public string SoapLoanRequest(string ssn, float loanAmount, float loanDuration)
        {
            var msg = "Error";

            //string ssnremove = "010101-0101";
            //float loanAm = 10.5F;
            //float Duarr = 10F;


            LoanRequest loanRequest = new LoanRequest {
                ssn = ssn, loanAmount = loanAmount, loanDuration = loanDuration
            };
            var corrId = Guid.NewGuid().ToString();

            worker = new Worker(QueueName);
            sender = new Sender(QueueName);
            var sended = sender.Send(loanRequest, corrId);

            if (sended)
            {
                msg = worker.Consume();
            }


            return(msg);
        }
예제 #2
0
파일: Sender.cs 프로젝트: Flazhed/Laurbaer
 public bool Send(LoanRequest loanRequest, string corrId)
 {
     try
     {
         using (var connection = connectionFactory.CreateConnection())
             using (var channel = connection.CreateModel())
             {
                 channel.ExchangeDeclare(exchange: ExchangeName, type: "direct");
                 var props = channel.CreateBasicProperties();
                 props.CorrelationId = corrId;
                 props.ReplyTo       = queueName;
                 var message = JsonConvert.SerializeObject(loanRequest);
                 var body    = Encoding.UTF8.GetBytes(message);
                 channel.BasicPublish(exchange: ExchangeName,
                                      routingKey: RoutingKey,
                                      basicProperties: props,
                                      body: body);
             }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }