Exemplo n.º 1
0
        public RabbitMqOptionSet()
        {
            Add <string>("h|host:", "The host name of the broker", x => Host       = x);
            Add <string>("vhost:", "The virtual host to use", value => VirtualHost = value);
            Add <string>("u|username:"******"Username (if using basic credentials)", value => Username = value);
            Add <string>("p|password:"******"Password (if using basic credentials)", value => Password = value);
            Add <TimeSpan>("heartbeat:", "Heartbeat (for RabbitMQ)", value => Heartbeat            = value);
            Add <bool>("confirm:", "Publisher Confirmation", value => PublisherConfirmation        = value);
            Add <bool>("batch:", "Batch Publish", EnableBatch);

            Host        = "localhost";
            Username    = "******";
            Password    = "******";
            Heartbeat   = TimeSpan.Zero;
            VirtualHost = "/";
            Port        = 5672;

            Ssl                         = false;
            SslProtocol                 = SslProtocols.Tls12;
            SslServerName               = Host;
            AcceptablePolicyErrors      = SslPolicyErrors.RemoteCertificateNameMismatch;
            ClientCertificatePath       = "";
            ClientCertificatePassphrase = "";

            RequestedConnectionTimeout = TimeSpan.FromSeconds(10);
            MessageNameFormatter       = new RabbitMqMessageNameFormatter();

            PublisherConfirmation = false;
            EnableBatch(true);
        }
        public RabbitMqHostConfiguration(IRabbitMqBusConfiguration busConfiguration, IRabbitMqTopologyConfiguration topologyConfiguration)
            : base(busConfiguration)
        {
            _busConfiguration = busConfiguration;
            _hostSettings     = new ConfigurationHostSettings
            {
                Host        = "localhost",
                VirtualHost = "/",
                Port        = 5672,
                Username    = "******",
                Password    = "******"
            };

            var messageNameFormatter = new RabbitMqMessageNameFormatter();

            _hostTopology = new RabbitMqHostTopology(this, messageNameFormatter, _hostSettings.HostAddress, topologyConfiguration);

            ReceiveTransportRetryPolicy = Retry.CreatePolicy(x =>
            {
                x.Handle <ConnectionException>();
                x.Handle <MessageNotConfirmedException>(exception => exception.Message.Contains("CONNECTION_FORCED"));

                x.Ignore <AuthenticationFailureException>();

                x.Exponential(1000, TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(3));
            });

            _connectionContext = new Recycle <IConnectionContextSupervisor>(() => new ConnectionContextSupervisor(this, topologyConfiguration));
        }
Exemplo n.º 3
0
        public void Setup()
        {
            _nameFormatter       = new RabbitMqMessageNameFormatter();
            _entityNameFormatter = new MessageNameFormatterEntityNameFormatter(_nameFormatter);
            _publishTopology     = new RabbitMqPublishTopology(RabbitMqBusFactory.MessageTopology);

            _builder = new PublishEndpointBrokerTopologyBuilder(PublishBrokerTopologyOptions.MaintainHierarchy);
        }
Exemplo n.º 4
0
        public RabbitMqBusConfiguration(IRabbitMqTopologyConfiguration topology)
            : base(topology)
        {
            _hosts = new HostCollection <IRabbitMqHostConfiguration>();

            _exchangeTypeSelector = new FanoutExchangeTypeSelector();
            _messageNameFormatter = new RabbitMqMessageNameFormatter();
        }
        public ConfigurationHostSettings()
        {
            MessageNameFormatter = new RabbitMqMessageNameFormatter();

            var connectionFactory = new ConnectionFactory();
            SslProtocol = connectionFactory.Ssl.Version;
            AcceptablePolicyErrors = connectionFactory.Ssl.AcceptablePolicyErrors;
        }
        public ConfigurationHostSettings()
        {
            MessageNameFormatter = new RabbitMqMessageNameFormatter();

            var connectionFactory = new ConnectionFactory();

            SslProtocol            = connectionFactory.Ssl.Version;
            AcceptablePolicyErrors = connectionFactory.Ssl.AcceptablePolicyErrors;
        }
Exemplo n.º 7
0
        public RabbitMqTestHarness(string inputQueueName = null)
        {
            Username = "******";
            Password = "******";

            InputQueueName = inputQueueName ?? "input_queue";

            NameFormatter = new RabbitMqMessageNameFormatter();

            HostAddress = new Uri("rabbitmq://localhost/test/");
        }
        public ConfigurationHostSettings()
        {
            MessageNameFormatter = new RabbitMqMessageNameFormatter();

            var connectionFactory = new ConnectionFactory();
            SslProtocol = connectionFactory.Ssl.Version;
            AcceptablePolicyErrors = connectionFactory.Ssl.AcceptablePolicyErrors;

            PublisherConfirmation = true;

            ClientProvidedName = HostMetadataCache.Host.ProcessName;
        }
Exemplo n.º 9
0
        public ConfigurationHostSettings()
        {
            MessageNameFormatter = new RabbitMqMessageNameFormatter();

            var connectionFactory = new ConnectionFactory();

            SslProtocol            = connectionFactory.Ssl.Version;
            AcceptablePolicyErrors = connectionFactory.Ssl.AcceptablePolicyErrors;

            PublisherConfirmation = true;

            ClientProvidedName = HostMetadataCache.Host.ProcessName;
        }
Exemplo n.º 10
0
        public void Setup()
        {
            _nameFormatter       = new RabbitMqMessageNameFormatter();
            _entityNameFormatter = new MessageNameFormatterEntityNameFormatter(_nameFormatter);
            _consumeTopology     = new RabbitMqConsumeTopology(RabbitMqBusFactory.MessageTopology, new RabbitMqPublishTopology(RabbitMqBusFactory.MessageTopology));

            _builder = new ReceiveEndpointBrokerTopologyBuilder();

            _inputQueueName   = "input-queue";
            _builder.Queue    = _builder.QueueDeclare(_inputQueueName, true, false, false, new Dictionary <string, object>());
            _builder.Exchange = _builder.ExchangeDeclare(_inputQueueName, _consumeTopology.ExchangeTypeSelector.DefaultExchangeType, true, false,
                                                         new Dictionary <string, object>());
            _builder.QueueBind(_builder.Exchange, _builder.Queue, "", new Dictionary <string, object>());
        }
        public ConfigurationHostSettings()
        {
            MessageNameFormatter = new RabbitMqMessageNameFormatter();

            var defaultOptions = new SslOption();

            SslProtocol            = defaultOptions.Version;
            AcceptablePolicyErrors = defaultOptions.AcceptablePolicyErrors | SslPolicyErrors.RemoteCertificateChainErrors;

            PublisherConfirmation = true;

            ClientProvidedName = HostMetadataCache.Host.ProcessName;

//            _topology = new Lazy<IRabbitMqHostTopology>(() => new RabbitMqTopology(new FanoutExchangeTypeSelector(), MessageNameFormatter, HostAddress, TODO, TODO, TODO));
        }
Exemplo n.º 12
0
        private void BindMessages()
        {
            ConnectionFactory connectionFactory = _host.Settings.GetConnectionFactory();

            using IConnection connection = connectionFactory.CreateConnection(_host.Settings.Host);
            using IModel channel         = connection.CreateModel();

            var messageNameFormatter = new RabbitMqMessageNameFormatter();

            foreach (Type type in _messageTypes)
            {
                string source = messageNameFormatter.GetMessageName(type).Name;
                channel.ExchangeDeclare(source, ExchangeType.Fanout, true);
                channel.ExchangeBind(_destinationExchangeName, source, "");
            }
        }
        public RabbitMqHostConfiguration(IRabbitMqBusConfiguration busConfiguration, IRabbitMqTopologyConfiguration topologyConfiguration)
            : base(busConfiguration)
        {
            _busConfiguration = busConfiguration;
            _hostSettings     = new ConfigurationHostSettings
            {
                Host        = "localhost",
                VirtualHost = "/",
                Port        = 5672,
                Username    = "******",
                Password    = "******"
            };

            var exchangeTypeSelector = topologyConfiguration.Publish.ExchangeTypeSelector;
            var messageNameFormatter = new RabbitMqMessageNameFormatter();

            _hostTopology = new RabbitMqHostTopology(this, exchangeTypeSelector, messageNameFormatter, _hostSettings.HostAddress, topologyConfiguration);

            _connectionContext = new Recycle <IConnectionContextSupervisor>(() => new ConnectionContextSupervisor(this, topologyConfiguration));
        }