public EventDispatcher(BusOptions busOptions = null) { _options = busOptions ?? BusOptions.GetDefaultOptions(); var factory = new ConnectionFactory() { HostName = _options.HostName, Port = _options.Port, UserName = _options.UserName, Password = _options.Password, }; _connection = factory.CreateConnection(); _channel = _connection.CreateModel(); ExchangeName = _options.ExchangeName; _channel.ExchangeDeclare(exchange: ExchangeName, type: ExchangeType.Topic, durable: false, autoDelete: false, arguments: null); BuildDispatcherModel(); string queueName = null; if (_options.QueueName == null) { queueName = _channel.QueueDeclare().QueueName; } else { queueName = _channel.QueueDeclare(queue: _options.QueueName); } _channel.QueueBind(exchange: ExchangeName, queue: queueName, routingKey: "#", arguments: null); var consumer = new EventingBasicConsumer(_channel); consumer.Received += Consumer_Received; _channel.BasicConsume(queue: queueName, noAck: true, consumer: consumer); }
public EventPublisher(BusOptions options = null) { _options = options ?? BusOptions.GetDefaultOptions(); var factory = new ConnectionFactory() { HostName = _options.HostName, Port = _options.Port, UserName = _options.UserName, Password = _options.Password, }; _connection = factory.CreateConnection(); _channel = _connection.CreateModel(); _exchangeName = _options.ExchangeName; _channel.ExchangeDeclare(exchange: _exchangeName, type: ExchangeType.Topic, durable: false, autoDelete: false, arguments: null); }