// EasyNetQ Quick Start: https://github.com/EasyNetQ/EasyNetQ/wiki/Quick-Start // Management Console: http://localhost:15672/ // Naming Convention: https://derickbailey.com/2015/09/02/rabbitmq-best-practices-for-designing-exchanges-queues-and-bindings/ // Exchange: where the message are being published // Queue: where the exchgaes are being directed to // What I need: // // (YES) A message broker where I publish messages // (YES) A message broker where I subscribe to messages // When a consumer is processing a message, it can get a failure and process can shut down. // In those cases, message shouldn't be lost. // When a consumer is processing a message, // it can get a temporary failure. In those cases, the message // should be retriable. // More resources: // - Docker RabbitMQ cluster: https://github.com/bijukunjummen/docker-rabbitmq-cluster public static void Main(string[] args) { Console.WriteLine("Waiting for 5s to let the RabbitMQ start up"); Thread.Sleep(5000); var config = ConfigBuilder.Build(); var settings = new RabbitMQSettings(); ConfigurationBinder.Bind(config.GetSection("RabbitMQ"), settings); Console.WriteLine($"Starting the pub/sub sample on '{settings.Host}' rabbitmq instance."); var factory = new ConnectionFactory { HostName = settings.Host }; var conn = factory.CreateConnection(); var channel = conn.CreateModel(); channel.ExchangeDeclare(ExchangeName, ExchangeType.Fanout, false, false); channel.QueueDeclare(QueueName, false, false, false, null); channel.QueueDeclare(QueueName2, false, false, false, null); channel.QueueBind(QueueName, ExchangeName, RoutingKey, null); channel.QueueBind(QueueName2, ExchangeName, RoutingKey, null); var pubTask = new Publisher(conn).Start(); var subTask = new Subscriber(conn, QueueName).Start(); var subTask2 = new Subscriber(conn, QueueName2).Start(); Task.WhenAll(pubTask, subTask, subTask2).Wait(); }
public static void Main(string[] args) { var config = ConfigBuilder.Build(); var settings = new RabbitMQSettings(); ConfigurationBinder.Bind(config.GetSection("RabbitMQ"), settings); Console.WriteLine(settings.Host); }
// EasyNetQ Quick Start: https://github.com/EasyNetQ/EasyNetQ/wiki/Quick-Start // Management Console: http://localhost:15672/ // Exchange: where the message are being published // Queue: where the exchgaes are being directed to // What I need: // // (YES) A message broker where I publish messages // (YES) A message broker where I subscribe to messages // When a consumer is processing a message, it can get a failure and process can shut down. // In those cases, message shouldn't be lost. // When a consumer is processing a message, // it can get a temporary failure. In those cases, the message // should be retriable. // More resources: // - Docker RabbitMQ cluster: https://github.com/bijukunjummen/docker-rabbitmq-cluster public static void Main(string[] args) { var config = ConfigBuilder.Build(); var settings = config.Get <RabbitMQSettings>("RabbitMQ"); Console.WriteLine($"Starting the pub/sub sample on '{settings.Host}' rabbitmq instance."); var pubTask = new Publisher(settings.Host).Start(); var subTask = new Subscriber(settings.Host).Start(); Task.WhenAll(pubTask, subTask).Wait(); }