Advertisement
Guest User

Untitled

a guest
May 13th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. var factory = new ConnectionFactory()
  6. {
  7. UserName = "guest",
  8. Password = "guest",
  9. HostName = "localhost",
  10. VirtualHost = "103057"
  11. };
  12. using (var connection = factory.CreateConnection())
  13. using (var channel = connection.CreateModel())
  14. {
  15. channel.QueueDeclare("moja_koleja", false, false, false, null);
  16.  
  17. channel.BasicQos(0, 1, false);
  18. // send/receive message
  19. for (int i = 0; i < 10; i++)
  20. {
  21. IBasicProperties properties = channel.CreateBasicProperties();
  22. properties.Headers = new Dictionary<string, object>();
  23. properties.Headers.Add("naglowek", i);
  24.  
  25.  
  26. string message = "wiadomosc " + i;
  27. var body = Encoding.UTF8.GetBytes(message);
  28. channel.BasicPublish("", "moja_koleja", properties, body);
  29. }
  30. }
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement