Guest User

Untitled

a guest
Jul 25th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using RabbitMQ.Abstraction.Messaging;
  4. using RabbitMQ.Client;
  5. using RabbitMQ.Client.Framing;
  6.  
  7. namespace ConsoleApp1 {
  8. class Program {
  9. static void Main(string[] args) {
  10.  
  11. Console.WriteLine($"Start: {DateTime.UtcNow:o}");
  12.  
  13. var factory = new ConnectionFactory() {
  14. AutomaticRecoveryEnabled = true,
  15. Password = "***",
  16. UserName = "****",
  17. VirtualHost = "****",
  18. HostName = "******"
  19. };
  20.  
  21. using (var connection = factory.CreateConnection()) {
  22.  
  23. using (var channel = connection.CreateModel()) {
  24. for (int x = 0; x < 10000; x++) {
  25.  
  26. channel.QueueDeclare(queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null);
  27.  
  28. string message = "Hello World!";
  29. var body = Encoding.UTF8.GetBytes(message);
  30. {
  31. channel.BasicPublish(exchange: "", routingKey: "hello", basicProperties: null, body: body);
  32. }
  33. }
  34. }
  35. }
  36.  
  37. Console.WriteLine($"End: {DateTime.UtcNow:o}");
  38.  
  39. Console.WriteLine(" Press [enter] to exit.");
  40. Console.ReadLine();
  41. }
  42. }
  43. }
Add Comment
Please, Sign In to add comment