SHARE
TWEET

Untitled

a guest Jun 17th, 2019 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. try {
  2.             var factory = new ConnectionFactory() { HostName = "xxx" , UserName ="xxx", Password="xxx"};
  3.             using(var connection = factory.CreateConnection())
  4.             using(var channel = connection.CreateModel())
  5.             {
  6.                 channel.ExchangeDeclare(exchange: "call_notify", type: "fanout");
  7.  
  8.                 var queueName = channel.QueueDeclare().QueueName;
  9.                 channel.QueueBind(queue: queueName,
  10.                                   exchange: "call_notify",
  11.                                   routingKey: "");
  12.  
  13.                 var consumer = new EventingBasicConsumer(channel);
  14.                 consumer.Received += (model, ea) =>
  15.                 {
  16.                     var body = ea.Body;
  17.                     var message = Encoding.UTF8.GetString(body);
  18.                     Console.WriteLine(message);
  19.                 };
  20.                 channel.BasicConsume(queue: queueName,
  21.                                      autoAck: true,
  22.                                      consumer: consumer);
  23.  
  24.                 Console.WriteLine(" Press [enter] to exit.");
  25.                 Console.ReadLine();  // Program does'nt wait here in windows form based application
  26.             }
  27.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top