public void Initialize() { var factory = new ConnectionFactory { HostName = "localhost" }; _connection = factory.CreateConnection(); _channel = _connection.CreateModel(); _channel.ExchangeDeclare(exchange: ExchangeName, type: "fanout"); _logger.Log($"The exchange \"{ExchangeName}\" has been declared!"); }
public void Initialize() { var factory = new ConnectionFactory { HostName = "localhost" }; _connection = factory.CreateConnection(); _channel = _connection.CreateModel(); _channel.QueueDeclare(queue: ChannelName, durable: false, exclusive: false, autoDelete: false, arguments: null); _logger.Log($"The queue {ChannelName} has been declared!"); }
public void Initialize() { var factory = new ConnectionFactory { HostName = "localhost" }; _connection = factory.CreateConnection(); _channel = _connection.CreateModel(); _channel.ExchangeDeclare(exchange: ExchangeName, type: "fanout"); _queueName = _channel.QueueDeclare().QueueName; _channel.QueueBind(queue: _queueName, exchange: ExchangeName, routingKey: ""); _logger.Log($"The exchange \"{ExchangeName}\" has been declared and an anonymous queue has been bound to it!"); }
public void Initialize() { var factory = new ConnectionFactory { HostName = "localhost", DispatchConsumersAsync = true }; _connection = factory.CreateConnection(); _channel = _connection.CreateModel(); _channel.QueueDeclare(queue: ChannelName, durable: true, exclusive: false, autoDelete: false, arguments: null); _channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false); //don't want to get messages until I finish processing the current message, fetch messages one by one _logger.Log($"The queue \"{ChannelName}\" has been declared!"); }