private string nonBlockingRead(LoanBroker.model.LoanRequest loanRequest) { string returnString = "Could not send the message"; EventingBasicConsumer consumer; using (IModel channel = new ConnectionFactory() { HostName = Queues.RABBITMQ_HOSTNAME }.CreateConnection().CreateModel()) { channel.QueueDeclare(queue: Queues.LOANBROKER_OUT, durable: false, exclusive: false, autoDelete: false, arguments: null); consumer = new EventingBasicConsumer(channel); bool weDontHaveIt = true; consumer.Received += (model, ea) => { LoanBroker.model.LoanResponse loanResponse = JsonConvert.DeserializeObject<LoanBroker.model.LoanResponse>(Encoding.UTF8.GetString(ea.Body)); if (loanResponse.SSN == loanRequest.SSN) { weDontHaveIt = false; } else { // Return it to the queue channel.BasicReject(ea.DeliveryTag, true); } }; channel.BasicConsume(queue: Queues.LOANBROKER_OUT, noAck: true, consumer: consumer); while (weDontHaveIt) { System.Threading.Thread.Sleep(5); } } return returnString; }