Program.cs 898 B

123456789101112131415161718192021222324252627282930
  1. namespace metrics_collector
  2. {
  3. using System;
  4. using Amqp;
  5. class MetricsCollector
  6. {
  7. static void Main(string[] args)
  8. {
  9. string url = "amqp://localhost:61616";
  10. string address = "sampleQueue";
  11. Address a = new Address(url);
  12. Connection c = new Connection(a);
  13. Session s = new Session(c);
  14. ReceiverLink rl = new ReceiverLink(s, "receiver", address);
  15. Console.WriteLine("Receiving random metrics from " + url + "/" + address);
  16. while (true) {
  17. Message m = rl.Receive();
  18. rl.Accept(m);
  19. if (m != null) {
  20. Console.WriteLine("Got: " + m.Body.ToString());
  21. continue;
  22. }
  23. System.Threading.Thread.Sleep(1000);
  24. }
  25. }
  26. }
  27. }