Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. var factory = new ConnectionFactory(){ HostName = _rabbitMQ_Hostname, UserName = _rabbitMQ_Username, Password = _rabbitMQ_Password};
  2.  
  3. using (var connection = factory.CreateConnection())
  4. using (var channel = connection.CreateModel())
  5. {
  6. channel.QueueDeclare(queue: _autoCancellationPNS_QueueName,
  7. durable: true,
  8. exclusive: false,
  9. autoDelete: false,
  10. arguments: null);
  11.  
  12. string message = appointmentId.ToString();
  13. var body = Encoding.UTF8.GetBytes(message);
  14. IBasicProperties properties = channel.CreateBasicProperties();
  15. properties.DeliveryMode = 2;
  16. channel.BasicPublish(exchange: _rabbitMQ_Exchange,
  17. routingKey: _autoCancellationPNS_RoutingKey,
  18. basicProperties: properties,
  19. body: body);
  20. returnMessage.ShortMessage = "Added to queue";
  21. returnMessage.LongMessage = "Added to queue";
  22. logger.Debug("|Added to queue");
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement