Advertisement
Guest User

Untitled

a guest
Apr 16th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. using RabbitMQ.Client;
  2. using RabbitMQ.Client.Events;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace rabbitmq
  10. {
  11.  
  12. class Program
  13. {
  14. static void Main(string[] args)
  15. {
  16. var factory = new ConnectionFactory()
  17. {
  18. UserName = "dahjdrhx",
  19. Password = "ng-DairYiYJDTY9JyemWFB9By5WqxXcA",
  20. HostName = "eagle.rmq.cloudamqp.com",
  21. VirtualHost = "dahjdrhx"
  22. };
  23. using (var connection = factory.CreateConnection())
  24. using (var channel = connection.CreateModel())
  25. {
  26. channel.QueueDeclare("message_queue", true, false, false, null);
  27.  
  28. var consumer = new EventingBasicConsumer(channel);
  29. for (int i = 0; i < 100; i++)
  30. {
  31. string message = "aaaa" + i.ToString();
  32. var body = Encoding.UTF8.GetBytes(message);
  33. channel.BasicPublish("", "message_queue", null, body);
  34. }
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement