Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- var factory = new ConnectionFactory() { HostName = "xxx" , UserName ="xxx", Password="xxx"};
- using(var connection = factory.CreateConnection())
- using(var channel = connection.CreateModel())
- {
- channel.ExchangeDeclare(exchange: "call_notify", type: "fanout");
- var queueName = channel.QueueDeclare().QueueName;
- channel.QueueBind(queue: queueName,
- exchange: "call_notify",
- routingKey: "");
- var consumer = new EventingBasicConsumer(channel);
- consumer.Received += (model, ea) =>
- {
- var body = ea.Body;
- var message = Encoding.UTF8.GetString(body);
- Console.WriteLine(message);
- };
- channel.BasicConsume(queue: queueName,
- autoAck: true,
- consumer: consumer);
- Console.WriteLine(" Press [enter] to exit.");
- Console.ReadLine(); // Program does'nt wait here in windows form based application
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement