var factory = new ConnectionFactory(); factory.HostName = "localhost"; factory.UserName = "admin"; factory.Password = "admin"; using (var connection = factory.CreateConnection()) { using (var channel = connection.CreateModel()) { channel.ExchangeDeclare("topic_dev", "topic", true, false, null); channel.QueueDeclare("login", true, false, false, null); channel.QueueDeclare("signin", true, false, false, null); channel.QueueBind("login", "topic_dev", "#.login.#", null); channel.QueueBind("signin", "topic_dev", "#.signin.#", null); var properties = channel.CreateBasicProperties(); properties.DeliveryMode = 2; var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var body = ea.Body.ToArray(); var msg = Encoding.UTF8.GetString(body); Console.WriteLine($"login => {msg}, DeliveryTag={ea.DeliveryTag}, Redelivered={ea.Redelivered}, RoutingKey={ea.RoutingKey}"); channel.BasicAck(ea.DeliveryTag, false); }; channel.BasicConsume("login", false, consumer); var consumer1 = new EventingBasicConsumer(channel); consumer1.Received += (model, ea) => { var body = ea.Body.ToArray(); var msg = Encoding.UTF8.GetString(body); Console.WriteLine($"signin => {msg}, DeliveryTag={ea.DeliveryTag}, Redelivered={ea.Redelivered}, RoutingKey={ea.RoutingKey}"); channel.BasicAck(ea.DeliveryTag, false); }; channel.BasicConsume("signin", false, consumer1); string message = "I am jonney"; channel.BasicPublish("topic_dev", "login.signin", properties, Encoding.UTF8.GetBytes(message)); Console.WriteLine($"Send:{message}"); Console.ReadLine(); } }