I'm using RabbitMQ.Client inside many projects in .Net Framework 4.7.2.
Using the versions 5.X.X of the client was possible to wait incoming messages with simple code like this:
const string EXCHANGE_NAME = "EXCHANGE3"; ConnectionFactory factory = new ConnectionFactory(); IConnection connection = factory.CreateConnection()) IModel channel = connection.CreateModel()) channel.ExchangeDeclare(EXCHANGE_NAME, ExchangeType.Topic, false, true, null); string queueName = channel.QueueDeclare(); EventingBasicConsumer consumer = new EventingBasicConsumer(channel); consumer.Received += (o, e) => { string data = Encoding.ASCII.GetString(e.Body); Console.WriteLine("received: " + data); Thread.Sleep(1000); Console.WriteLine("done."); }; string consumerTag = channel.BasicConsume(queueName, true, consumer); channel.QueueBind(queueName, EXCHANGE_NAME, "myTopic");Now, with version 6.2.4, you need to append a line with Console.ReadLine() otherwise the application closes.
This is blocking because: all previous windows services, listening for messages and created by the library System.ServiceProcess.ServiceBase, closes immediately after start.