Esempio n. 1
0
        private static void handleRabbitMQOurBank(LoanRequest loanRequest)
        {
            //SSN;CreditScore;Amount;Duration
            string msg = string.Format("{0};{1};{2};{3}", loanRequest.SSN, loanRequest.CreditScore, loanRequest.Amount, loanRequest.Duration);

            HandleMessaging.SendMessage <string>(Queues.RABBITMQOURBANK_IN, msg);
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            Console.Title = "1 - Credit Score Fetcher";
            Console.SetWindowSize(80, 5);
            Console.WriteLine("<--Listening for messages on queue: " + Queues.LOANBROKER_IN);
            HandleMessaging.RecieveMessage(Queues.LOANBROKER_IN, (object model, BasicDeliverEventArgs ea) =>
            {
                Console.WriteLine("<--Message recieved on queue: " + Queues.LOANBROKER_IN);

                LoanRequest loanRequest;

                CreditScoreService.CreditScoreServiceClient service = new CreditScoreService.CreditScoreServiceClient();
                loanRequest = JsonConvert.DeserializeObject <LoanRequest>(Encoding.UTF8.GetString(ea.Body));

                Console.WriteLine("<--Message content:");
                Console.WriteLine("<--" + loanRequest);

                loanRequest.CreditScore = service.creditScore(loanRequest.SSN);

                Console.WriteLine("<--Enriched message content:");
                Console.WriteLine("<--" + loanRequest);

                Console.WriteLine("<--Sending message on queue: " + Queues.CREDITBUREAU_OUT);
                Console.WriteLine();
                HandleMessaging.SendMessage <LoanRequest>(Queues.CREDITBUREAU_OUT, loanRequest);
            });
        }
Esempio n. 3
0
        private static void handleRabbitMQJSONBank(LoanRequest loanRequest, string routingKey)
        {
            /*
             * String format from pdf:
             * string msg = "{\"ssn\":" + loanRequest.SSN + ",\"creditScore\":" + loanRequest.CreditScore.ToString() +
             *  ",\"loanAmount\":" + loanRequest.Amount.ToString() + ",\"loanDuration\":" + loanRequest.Duration +" }";
             *
             * but getting this from the bank:
             *
             * Exception: Something went wrong.Data should be sent like: { "ssn":1605789787,"loanAmount":10.0,"loanDuration":360,"rki":false}
             * Can not instantiate value of type[simple type, class dk.cphbusiness.si.banktemplate.JsonDTO.BankLoanDTO] from JSON String; no single-String constructor/factory method
             *
             */
            //string msg = "{ \"ssn\":" + loanRequest.SSN
            //    + ",\"loanAmount\":" + loanRequest.Amount.ToString(CultureInfo.CreateSpecificCulture("en-GB"))
            //    + ",\"loanDuration\":" + loanRequest.Duration.ToString()
            //    + ",\"rki\":false }";


            //TODO: 18/12/2015 A java group says we have to send a json object...
            string msg = "{ \"ssn\":" + loanRequest.SSN.Replace("-", "")
                         + ",\"creditScore\":" + loanRequest.CreditScore.ToString()
                         + ",\"loanAmount\":" + loanRequest.Amount.ToString(CultureInfo.CreateSpecificCulture("en-GB"))
                         + ",\"loanDuration\":" + loanRequest.Duration + " }";

            Console.WriteLine("--> Sending " + msg + " to cphbusiness.bankJSON");
            HandleMessaging.SendMessage("cphbusiness.bankJSON", routingKey, Queues.RABBITMQJSONBANK_OUT, msg, "fanout");
        }
        static void Main(string[] args)
        {
            Console.Write("-->Number of messages to send: ");
            int messages = Int32.Parse(Console.ReadLine());

            Console.WriteLine("\n\t<--Started sending messages!");
            for (int i = 0; i < messages; i++)
            {
                HandleMessaging.SendMessage <LoanRequest>(Queues.LOANBROKER_IN, new LoanRequest()
                {
                    Amount   = 100,
                    Duration = 12,
                    SSN      = "123456-7890"
                });
                Console.WriteLine("\t<--Messages sent: " + (i + 1) + "/" + messages);
            }
            Console.WriteLine("\t<--Stopped sending messages!\n");

            Console.Write("-->Press [Enter] to start receiving messages.");
            Console.ReadLine();

            Console.WriteLine("\n\t<--Started receiving messages!");

            var consumer = HandleMessaging.RecieveMessage(Queues.DELEGATER_OUT, (object model, BasicDeliverEventArgs ea) =>
            {
                byte[] body    = ea.Body;
                string message = Encoding.UTF8.GetString(body);
                Console.WriteLine("\t<--Message: " + message + " on queue: " + ea.RoutingKey);
            });
            //Utility.HandleMessaging.SendMessage<LoanRequest>("group1_loanbroker_in", new LoanRequest() { Amount = 100, Duration = 12, SSN = "123456-7890" });
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Console.Title = "Translator JSON";
            Console.SetWindowSize(80, 5);

            string routingKey = LoanBroker.Utility.BankingUtility.ROUTING_KEY_RabbitMQJSONBank;

            Console.WriteLine("<--Listening for messages on exchange: " + Queues.RULEBASEFETCHER_OUT + " with routing key: " + routingKey);

            HandleMessaging.RecieveMessage(Queues.RULEBASEFETCHER_OUT, string.Format("QUEUE_{0}", routingKey), routingKey, (object model, BasicDeliverEventArgs ea) =>
            {
                Console.WriteLine("<--Message recieved on exchange: " + Queues.RULEBASEFETCHER_OUT);

                LoanRequest loanRequest;

                loanRequest = JsonConvert.DeserializeObject <LoanRequest>(Encoding.UTF8.GetString(ea.Body));

                Console.WriteLine("<--Message content:");
                Console.WriteLine("<--" + loanRequest);
                Console.WriteLine();

                handleRabbitMQJSONBank(loanRequest, routingKey);
            }
                                           );
        }
        public static void Main(string[] args)
        {
            Console.Title = "3 - RecipientList";
            Console.SetWindowSize(80, 5);
            Console.WriteLine("<--Listening for messages on queue: " + Queues.BANKFETCHER_OUT);
            HandleMessaging.RecieveMessage(Queues.BANKFETCHER_OUT, (object model, BasicDeliverEventArgs ea) =>
            {
                Console.WriteLine("<--Message recieved on queue: " + Queues.BANKFETCHER_OUT);

                LoanRequest loanRequest;

                loanRequest = JsonConvert.DeserializeObject <LoanRequest>(Encoding.UTF8.GetString(ea.Body));

                Console.WriteLine("<--Message content:");
                Console.WriteLine("<--" + loanRequest);
                Console.WriteLine();


                /*
                 *  We need Routing: https://www.rabbitmq.com/tutorials/tutorial-four-dotnet.html
                 *  That means an Exchange... So new methods to send and recieve..
                 */

                if (loanRequest.Banks != null)
                {
                    foreach (Bank bank in loanRequest.Banks)
                    {
                        //TDK: is this the best way to do Routing key? I think so.
                        HandleMessaging.SendMessage <LoanRequest>(Queues.RULEBASEFETCHER_OUT, bank.RoutingKey, string.Empty, loanRequest);
                        Console.WriteLine("<--Sending message on exchange: " + Queues.RULEBASEFETCHER_OUT + " with routing key: " + bank.RoutingKey);
                        Console.WriteLine();
                    }
                }
            });
        }
Esempio n. 7
0
        public static void Main(string[] args)
        {
            Console.Title = "RabbitMQJSONBankNormalizer";
            Console.SetWindowSize(80, 5);
            Console.WriteLine("Listening on queue: " + Queues.RABBITMQJSONBANK_OUT);

            HandleMessaging.RecieveMessage(Queues.RABBITMQJSONBANK_OUT, (object model, BasicDeliverEventArgs ea) =>
            {
                Console.WriteLine("<--Message recieved on queue: " + Queues.RABBITMQJSONBANK_OUT);

                LoanResponse loanResponse;
                JsonBankResponse bankResponse;

                string msg = Encoding.UTF8.GetString(ea.Body);

                try
                {
                    bankResponse = JsonConvert.DeserializeObject <JsonBankResponse>(msg);
                    loanResponse = new LoanResponse()
                    {
                        InterestRate = bankResponse.InterestRate,
                        SSN          = bankResponse.SSN,
                        BankName     = ea.RoutingKey.Split('_')[1] // Gets the bank name from the queue name
                    };

                    Console.WriteLine("<--Sending message on queue: " + Queues.NORMALIZER_OUT);
                    Console.WriteLine();
                    HandleMessaging.SendMessage <LoanResponse>(Queues.NORMALIZER_OUT, loanResponse);
                }
                catch (Exception ex)
                {
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.WriteLine(ex.Message);
                    Console.BackgroundColor = ConsoleColor.Black;

                    /*
                     * String format from pdf:
                     * string msg = "{\"ssn\":" + loanRequest.SSN + ",\"creditScore\":" + loanRequest.CreditScore.ToString() +
                     *     ",\"loanAmount\":" + loanRequest.Amount.ToString() + ",\"loanDuration\":" + loanRequest.Duration +" }";
                     *
                     * but getting this from the bank:
                     *
                     * Exception: Something went wrong.Data should be sent like: { "ssn":1605789787,"loanAmount":10.0,"loanDuration":360,"rki":false}
                     * Can not instantiate value of type[simple type, class dk.cphbusiness.si.banktemplate.JsonDTO.BankLoanDTO] from JSON String; no single-String constructor/factory method
                     *
                     *  Gonna send the pdf version, and just catch the exception here...
                     */
                }
            });
        }
Esempio n. 8
0
        private static void _timeOut_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (_responeList.Count > 0)
            {
                Dictionary <string, Response> responeListCopy = new Dictionary <string, Response>();
                lock (_listLockObject)
                {
                    foreach (string key in _responeList.Keys)
                    {
                        responeListCopy.Add(key, _responeList[key]);
                    }
                }

                foreach (string ssn in responeListCopy.Keys)
                {
                    if (responeListCopy[ssn].LastResponseTime < DateTime.Now.AddMilliseconds(TIMEOUT))
                    {
                        // Do some sweet aggregating!
                        //responeList[ssn].LoanResponses.Sort(new LoanResponseComparer());
                        int     idx          = int.MinValue;
                        decimal LowestOutPut = decimal.MaxValue;
                        for (int i = 0; i < responeListCopy[ssn].LoanResponses.Count; i++)
                        {
                            if (responeListCopy[ssn].LoanResponses[i].InterestRate < LowestOutPut)
                            {
                                LowestOutPut = responeListCopy[ssn].LoanResponses[i].InterestRate;
                                idx          = i;
                            }
                        }

                        if (idx > int.MinValue)
                        {
                            Console.WriteLine("<--Sending message on queue: " + Queues.LOANBROKER_OUT);
                            Console.WriteLine("Amount of bank responses: " + _responeList[ssn].LoanResponses.Count.ToString() + " for SSN: " + ssn);
                            Console.WriteLine();
                            // Need a TTL on this message....
                            HandleMessaging.SendMessage <LoanResponse>(
                                Queues.LOANBROKER_OUT,
                                responeListCopy[ssn].LoanResponses[idx],
                                TTL);
                            lock (_listLockObject)
                            {
                                _responeList.Remove(ssn);
                            }
                        }
                    }
                }
            }
        }
        private static void handleWebServiceBank(LoanRequest loanRequest)
        {
            WebServiceBank.WebServiceBank webBank = new WebServiceBank.WebServiceBank();
            decimal msg = webBank.ProcessLoanRequest(loanRequest.SSN, loanRequest.CreditScore, loanRequest.Amount, loanRequest.Duration);
            //TODO: Send loanrequest info aswell as decimal msg
            //HandleMessaging.SendMessage<decimal>(Queues.WEBSERVICEBANK_OUT, msg);
            LoanResponse loanResponse = new LoanResponse()
            {
                SSN          = loanRequest.SSN,
                BankName     = "Our Web Bank",
                InterestRate = msg
            };

            HandleMessaging.SendMessage <LoanResponse>(Queues.NORMALIZER_OUT, loanResponse);
        }
Esempio n. 10
0
        public static void Main(string[] args)
        {
            //A timer to handle timeouts.
            _timeOut.Interval = TIMEOUT / 10;
            _timeOut.Enabled  = true;
            _timeOut.Elapsed += _timeOut_Elapsed;


            Console.Title = "Aggregator";
            Console.SetWindowSize(80, 5);
            Console.WriteLine("Listening on queue: " + Queues.NORMALIZER_OUT);

            HandleMessaging.RecieveMessage(Queues.NORMALIZER_OUT, (object model, BasicDeliverEventArgs ea) =>
            {
                Console.WriteLine("<--Message recieved on queue: " + Queues.NORMALIZER_OUT);

                LoanResponse loanResponse;

                loanResponse = JsonConvert.DeserializeObject <LoanResponse>(Encoding.UTF8.GetString(ea.Body));

                lock (_listLockObject)
                {
                    if (!_responeList.ContainsKey(loanResponse.SSN))
                    {
                        // New SSN
                        _responeList.Add(loanResponse.SSN,
                                         new Response()
                        {
                            LoanResponses = new List <LoanResponse>()
                        }
                                         );
                    }
                }

                if (_responeList.ContainsKey(loanResponse.SSN))
                {
                    lock (_listLockObject)
                    {
                        _responeList[loanResponse.SSN].LastResponseTime = DateTime.Now;
                        _responeList[loanResponse.SSN].LoanResponses.Add(loanResponse);
                    }
                    handleListStuff();
                }
                //else
                // Throw some exception or logit
            });
        }
        static void Main(string[] args)
        {
            string routingKey = LoanBroker.Utility.BankingUtility.ROUTING_KEY_RabbitMQJSONBank;


            Console.Title = "RabbitMQJSONBankNormalizer";
            //Console.SetWindowSize(80, 5);
            Console.WriteLine("Listening on queue: " + Queues.RABBITMQJSONBANK_OUT);

            HandleMessaging.RecieveMessage(Queues.RABBITMQJSONBANK_OUT, (object model, BasicDeliverEventArgs ea) =>
            {
                Console.WriteLine("<--Message recieved on queue: " + Queues.RABBITMQJSONBANK_OUT);

                string msgIn = Encoding.UTF8.GetString(ea.Body);

                Console.WriteLine("Message is: " + msgIn);

                Console.WriteLine("<--Sending message on queue: " + Queues.NORMALIZER_OUT);
                Console.WriteLine();
            });

            /*
             * String format from pdf:
             * string msg = "{\"ssn\":" + loanRequest.SSN + ",\"creditScore\":" + loanRequest.CreditScore.ToString() +
             *  ",\"loanAmount\":" + loanRequest.Amount.ToString() + ",\"loanDuration\":" + loanRequest.Duration +" }";
             *
             * but getting this from the bank:
             *
             * Exception: Something went wrong.Data should be sent like: { "ssn":1605789787,"loanAmount":10.0,"loanDuration":360,"rki":false}
             * Can not instantiate value of type[simple type, class dk.cphbusiness.si.banktemplate.JsonDTO.BankLoanDTO] from JSON String; no single-String constructor/factory method
             *
             */
            //string msg = "{ \"ssn\":1605789787,\"loanAmount\":10.0,\"loanDuration\":360,\"rki\":false}";
            string msg = "{ \"ssn\":1605789787,\"creditScore\":598,\"loanAmount\":10.0,\"loanDuration\":360}";

            //string msg = "{ \"ssn\":" + loanRequest.SSN
            //    + ",\"loanAmount\":" + loanRequest.Amount.ToString(CultureInfo.CreateSpecificCulture("en-GB"))
            //    + ",\"loanDuration\":" + loanRequest.Duration.ToString()
            //    + ",\"rki\":false }";
            //string msg = "{ \"ssn\":" + loanRequest.SSN.Replace("-", "")
            //    + ",\"creditScore\":"  + loanRequest.CreditScore.ToString()
            //    + ",\"loanAmount\":" + loanRequest.Amount.ToString(CultureInfo.CreateSpecificCulture("en-GB"))
            //    + ",\"loanDuration\":" + loanRequest.Duration + " }";

            Console.WriteLine("--> Sending " + msg + " to cphbusiness.bankJSON");
            HandleMessaging.SendMessage("cphbusiness.bankJSON", routingKey, Queues.RABBITMQJSONBANK_OUT, msg, "fanout");
        }
Esempio n. 12
0
        public static void Main(string[] args)
        {
            Console.Title = "2 - RuleBase Fetcher";
            Console.SetWindowSize(80, 5);
            Console.WriteLine("<--Listening for messages on queue: " + Queues.CREDITBUREAU_OUT);
            HandleMessaging.RecieveMessage(Queues.CREDITBUREAU_OUT, (object model, BasicDeliverEventArgs ea) =>
            {
                Console.WriteLine("<--Message recieved on queue: " + Queues.CREDITBUREAU_OUT);

                LoanRequest loanRequest;

                loanRequest = JsonConvert.DeserializeObject <LoanRequest>(Encoding.UTF8.GetString(ea.Body));

                Console.WriteLine("<--Message content:");
                Console.WriteLine("<--" + loanRequest);

                RuleBaseServiceSoapClient service;
                ArrayOfString strings;

                service           = new RuleBaseServiceSoapClient();
                loanRequest.Banks = new List <Bank>();
                strings           = service.GetBanks();

                foreach (string jSonRepOfBank in strings)
                {
                    Bank bank;
                    bank = JsonConvert.DeserializeObject <Bank>(jSonRepOfBank);

                    if (loanRequest.CreditScore >= bank.MinCreditScore &&
                        loanRequest.CreditScore <= bank.MaxCreditScore &&
                        loanRequest.Amount >= bank.MinAmount &&
                        loanRequest.Amount <= bank.MaxAmount &&
                        loanRequest.Duration >= bank.MinDuration &&
                        loanRequest.Duration <= bank.MaxDuration)
                    {
                        loanRequest.Banks.Add(bank);
                    }
                }

                Console.WriteLine("<--Enriched message content:");
                Console.WriteLine("<--" + loanRequest);

                Console.WriteLine("<--Sending message on queue: " + Queues.BANKFETCHER_OUT);
                Console.WriteLine();
                HandleMessaging.SendMessage <LoanRequest>(Queues.BANKFETCHER_OUT, loanRequest);
            });
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            Console.Title = "RabbitMQBank";
            Console.SetWindowPosition(0, 0);
            Console.SetWindowSize(80, 5);
            Console.WriteLine("<--Listening for messages on queue: " + Queues.RABBITMQOURBANK_IN);
            HandleMessaging.RecieveMessage(Queues.RABBITMQOURBANK_IN, (object model, BasicDeliverEventArgs ea) =>
            {
                Console.WriteLine("<--Message recieved on queue: " + Queues.RABBITMQOURBANK_IN);

                byte[] inBody  = ea.Body;
                string message = Encoding.UTF8.GetString(inBody);

                Console.WriteLine("<--Message content:");
                Console.WriteLine("<--" + message);

                //SSN;CreditScore;Amount;Duration
                message         = message.Replace("\"", "");
                string[] parts  = message.Split(';');
                string ssn      = parts[0];
                int creditScore = 0;
                int.TryParse(parts[1], out creditScore);
                decimal amount = 0;
                decimal.TryParse(parts[2], out amount);
                int duration = 0;
                int.TryParse(parts[3], out duration);

                LoanBroker.model.LoanResponse loanResponse = new LoanBroker.model.LoanResponse()
                {
                    InterestRate = BankingUtility.ProcessLoanRequest(ssn, creditScore, amount, duration),
                    BankName     = "Our RabbitMQ Bank",
                    SSN          = ssn
                };

                //decimal sendMessage = BankingUtility.ProcessLoanRequest(ssn, creditScore, amount, duration);

                string msg = JsonConvert.SerializeObject(loanResponse);

                Console.WriteLine("<--Sending message on queue: " + Queues.RABBITMQOURBANK_OUT + " > " + msg);
                Console.WriteLine();

                HandleMessaging.SendMessage <LoanBroker.model.LoanResponse>(Queues.RABBITMQOURBANK_OUT, loanResponse);
            });
        }
Esempio n. 14
0
        public static void Main(string[] args)
        {
            Console.Title = "RabbitMQOurBankNormalizer";
            Console.SetWindowSize(80, 5);
            HandleMessaging.RecieveMessage(Queues.RABBITMQOURBANK_OUT, (object model, BasicDeliverEventArgs ea) =>
            {
                Console.WriteLine("<--Message recieved on queue: " + Queues.RABBITMQOURBANK_OUT);

                LoanResponse loanResponse;

                string s = Encoding.UTF8.GetString(ea.Body);

                //TODO: TDK: Error here.. Gets a loan request and not a ourbankresponse
                loanResponse = JsonConvert.DeserializeObject <LoanResponse>(Encoding.UTF8.GetString(ea.Body));

                Console.WriteLine("<--Sending message on queue: " + Queues.NORMALIZER_OUT);
                Console.WriteLine();
                HandleMessaging.SendMessage <LoanResponse>(Queues.NORMALIZER_OUT, loanResponse);
            });
        }
Esempio n. 15
0
        private static void handleRabbitMQXMLBank(LoanRequest loanRequest, string routingKey)
        {
            DateTime dtDuration = new DateTime(1970, 1, 1).AddMonths(loanRequest.Duration);

            /*
             *
             * Exception: Something went wrong. Data should be sent like:
             * <LoanRequest>   <ssn>12345678</ssn>   <creditScore>685</creditScore>   <loanAmount>10.0</loanAmount>   <loanDuration>1970-01-01 01:00:00.0 CET</loanDuration> </LoanRequest>     ParseError at [row,col]:[1,1]
             * Message: Content is not allowed in prolog.
             *
             */
            string msg = string.Format("<LoanRequest><ssn>{0}</ssn><creditScore>{1}</creditScore><loanAmount>{2}</loanAmount><loanDuration>{3}</loanDuration></LoanRequest>",
                                       loanRequest.SSN,
                                       loanRequest.CreditScore.ToString(),
                                       loanRequest.Amount.ToString(CultureInfo.CreateSpecificCulture("en-GB")),
                                       dtDuration.ToString("yyyy-MM-dd HH:mm:ss:ff CET") // since we dont care about hours and so on, time zone info is useless
                                       );

            //string msg = "<LoanRequest>   <ssn>12345678</ssn>   <creditScore>685</creditScore>   <loanAmount>10.0</loanAmount>   <loanDuration>1970-01-01 01:00:00.0 CET</loanDuration> </LoanRequest>";
            HandleMessaging.SendMessage("cphbusiness.bankXML", string.Empty, Queues.RABBITMQXMLBANK_OUT, msg, "fanout");
        }
        public static void Main(string[] args)
        {
            Console.Title = "RabbitMQXMLBankNormalizer";
            Console.SetWindowSize(80, 5);
            HandleMessaging.RecieveMessage(Queues.RABBITMQXMLBANK_OUT, (object model, BasicDeliverEventArgs ea) =>
            {
                Console.WriteLine("<--Message recieved on queue: " + Queues.RABBITMQXMLBANK_OUT);
                try
                {
                    LoanResponse loanResponse;
                    XMLBankResponse bankResponse;
                    System.Xml.Serialization.XmlSerializer serializer;

                    serializer = new System.Xml.Serialization.XmlSerializer(typeof(XMLBankResponse));

                    using (TextReader reader = new StringReader(Encoding.UTF8.GetString(ea.Body)))
                    {
                        bankResponse = serializer.Deserialize(reader) as XMLBankResponse;

                        loanResponse = new LoanResponse()
                        {
                            InterestRate = bankResponse.InterestRate,
                            SSN          = bankResponse.SSN,
                            BankName     = ea.RoutingKey.Split('_')[1] // Gets the bank name from the queue name
                        };
                    }

                    Console.WriteLine("<--Sending message on queue: " + Queues.NORMALIZER_OUT);
                    Console.WriteLine();
                    HandleMessaging.SendMessage <LoanResponse>(Queues.NORMALIZER_OUT, loanResponse);
                }
                catch (Exception ex)
                {
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.WriteLine(ex.Message);
                    Console.BackgroundColor = ConsoleColor.Black;
                }
            });
        }
        public string GetLoanQuoute(string ssn, decimal amount, int duration)
        {
            if (ssn.Length != 11)
            {
                throw new ArgumentException("SSN must be in the format 'xxxxxx-xxxx'");
            }
            if (ssn.Substring(6, 1) != "-")
            {
                throw new ArgumentException("SSN must be in the format 'xxxxxx-xxxx'");
            }

            if (amount <= 0)
            {
                throw new ArgumentException("Amount must be greater than 0");
            }
            if (duration <= 0)
            {
                throw new ArgumentException("Duration must be greater than 0");
            }

            LoanBroker.model.LoanRequest loanRequest = new LoanBroker.model.LoanRequest()
            {
                Amount   = amount,
                Duration = duration,
                SSN      = ssn
            };
            string returnString = "Could not send the message";

            // Do some stupid looping and "delete" old messages?


            if (HandleMessaging.SendMessage <LoanBroker.model.LoanRequest>(Queues.LOANBROKER_IN, loanRequest))
            {
                returnString = blockingRead(loanRequest);
            }
            return(returnString);
        }