protected override void OnConnect(object sender, EventArgs e) { using (IModel channel = RabbitMqConnection.CreateChannel(this)) { RabbitMqConnection.CreateExchange(channel, MessageMetadata.RpcDestination, ExchangeType.Topic); } }
protected override void OnConnect(object sender, EventArgs e) { if (RabbitMqConnection.RegisteredConnectors.ContainsKey(Id)) { return; } IModel channel = RabbitMqConnection.CreateChannel(this); RabbitMqConnection.ConfigureChannel(channel, BrokerConfiguration.ChannelConfiguration); _eventingBasicConsumer = RabbitMqConnection.CreateEventingBasicConsumer(channel); _eventingBasicConsumer.Received += EventingBasicConsumerOnReceived; foreach (BrokerSubscriberConfiguration config in BrokerConfiguration.BrokerSubscriberConfiguration) { RabbitMqConnection.CreateExchange(channel, config.ExchangeName, config.ExchangeType); config.QueueName = RabbitMqConnection.CreateQueue(channel, config.QueueName, config.Exclusive, config.Durable, config.AutoDelete); switch (config.ExchangeType) { case ExchangeType.Topic: case ExchangeType.Direct: if (config.Topic != null) { foreach (string topic in config.Topic) { RabbitMqConnection.CreateBinding(channel, config.QueueName, config.ExchangeName, topic); } } else { foreach (KeyValuePair <Type, List <Action <object, MessageMetadata> > > obj in _registerMethodDictionary) { if (!obj.Key.IsGenericType) { RabbitMqConnection.CreateBinding(channel, config.QueueName, config.ExchangeName, obj.Key.Name); } } } break; case ExchangeType.Fanout: RabbitMqConnection.CreateBinding(channel, config.QueueName, config.ExchangeName); break; } RabbitMqConnection.ConsumeQueue(this, channel, config.QueueName, Id.ToString(), true, _eventingBasicConsumer); } }