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));
        }
Ejemplo n.º 2
0
        public RabbitMqHost(IRabbitMqHostConfiguration hostConfiguration, IRabbitMqHostTopology hostTopology)
            : base(hostConfiguration, hostTopology)
        {
            _hostConfiguration = hostConfiguration;
            _hostTopology      = hostTopology;

            Add(hostConfiguration.ConnectionContextSupervisor);
        }
Ejemplo n.º 3
0
        public ConnectionContextFactory(IRabbitMqHostConfiguration configuration, IRabbitMqHostTopology hostTopology)
        {
            _configuration = configuration;
            _hostTopology  = hostTopology;

            _description = configuration.Settings.ToDescription();

            _connectionFactory = new Lazy <ConnectionFactory>(_configuration.Settings.GetConnectionFactory);
        }
Ejemplo n.º 4
0
        public ConnectionContextFactory(RabbitMqHostSettings settings, IRabbitMqHostTopology topology)
        {
            _settings = settings;
            _topology = topology;

            _description = settings.ToDebugString();

            _connectionFactory = new Lazy <ConnectionFactory>(settings.GetConnectionFactory);
        }
Ejemplo n.º 5
0
        public RabbitMqHostConfiguration(IRabbitMqBusConfiguration busConfiguration, RabbitMqHostSettings hostSettings, IRabbitMqHostTopology hostTopology)
        {
            _busConfiguration = busConfiguration;
            _hostSettings     = hostSettings;
            _hostTopology     = hostTopology;

            _host = new RabbitMqHost(this);

            Description = FormatDescription(hostSettings);
        }
Ejemplo n.º 6
0
        public RabbitMqConnectionCache(RabbitMqHostSettings settings, IRabbitMqHostTopology topology, ITaskSupervisor supervisor)
        {
            _settings          = settings;
            _topology          = topology;
            _connectionFactory = new Lazy <ConnectionFactory>(settings.GetConnectionFactory);

            _description = settings.ToDebugString();

            _cacheTaskScope = supervisor.CreateScope($"{TypeMetadataCache<RabbitMqConnectionCache>.ShortName} - {_description}", CloseScope);
        }
Ejemplo n.º 7
0
        public RabbitMqConnectionContext(IConnection connection, RabbitMqHostSettings hostSettings, IRabbitMqHostTopology topology, string description,
                                         CancellationToken cancellationToken)
            : base(new PayloadCache(), cancellationToken)
        {
            _connection  = connection;
            HostSettings = hostSettings;
            Topology     = topology;

            Description = description;

            _taskScheduler = new LimitedConcurrencyLevelTaskScheduler(1);

            connection.ConnectionShutdown += OnConnectionShutdown;
        }
Ejemplo n.º 8
0
        public RabbitMqHost(RabbitMqHostSettings settings, IRabbitMqHostTopology topology)
        {
            _settings = settings;
            _topology = topology;

            var exceptionFilter = Retry.Selected <RabbitMqConnectionException>();

            ReceiveEndpoints = new ReceiveEndpointCollection();

            _connectionRetryPolicy = exceptionFilter.Exponential(1000, TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(1));

            _supervisor = new TaskSupervisor($"{TypeMetadataCache<RabbitMqHost>.ShortName} - {_settings.ToDebugString()}");

            _connectionCache = new RabbitMqConnectionCache(settings, _topology, _supervisor);
        }
Ejemplo n.º 9
0
        public RabbitMqHost(IRabbitMqHostConfiguration hostConfiguration, IRabbitMqHostTopology hostTopology)
            : base(hostConfiguration, hostTopology)
        {
            _hostConfiguration = hostConfiguration;
            _hostTopology      = hostTopology;

            ConnectionRetryPolicy = Retry.CreatePolicy(x =>
            {
                x.Handle <RabbitMqConnectionException>();

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

            ConnectionContextSupervisor = new RabbitMqConnectionContextSupervisor(hostConfiguration, hostTopology);
        }
Ejemplo n.º 10
0
        public ConnectionContextFactory(IRabbitMqHostConfiguration configuration, IRabbitMqHostTopology hostTopology)
        {
            _configuration = configuration;
            _hostTopology  = hostTopology;

            _description = configuration.Settings.ToDescription();

            _connectionRetryPolicy = Retry.CreatePolicy(x =>
            {
                x.Handle <RabbitMqConnectionException>();

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

            _connectionFactory = new Lazy <ConnectionFactory>(_configuration.Settings.GetConnectionFactory);
        }
Ejemplo n.º 11
0
        public RabbitMqConnectionContext(IConnection connection, IRabbitMqHostConfiguration configuration, IRabbitMqHostTopology hostTopology,
                                         string description, CancellationToken cancellationToken)
            : base(cancellationToken)
        {
            _connection = connection;

            Description           = description;
            HostAddress           = configuration.HostAddress;
            PublisherConfirmation = configuration.PublisherConfirmation;
            Topology = hostTopology;

            StopTimeout = TimeSpan.FromSeconds(30);

            _taskScheduler = new LimitedConcurrencyLevelTaskScheduler(1);

            connection.ConnectionShutdown += OnConnectionShutdown;
        }
Ejemplo n.º 12
0
        public RabbitMqHost(IRabbitMqBusConfiguration busConfiguration, RabbitMqHostSettings settings, IRabbitMqHostTopology topology)
        {
            _settings = settings;
            _topology = topology;

            ReceiveEndpoints = new ReceiveEndpointCollection();

            ConnectionRetryPolicy = Retry.CreatePolicy(x =>
            {
                x.Handle <RabbitMqConnectionException>();

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

            ConnectionCache = new RabbitMqConnectionCache(settings, _topology);

            ReceiveEndpointFactory = new RabbitMqReceiveEndpointFactory(busConfiguration, this);
        }
        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));
        }
Ejemplo n.º 14
0
        public RabbitMqConnectionContext(IConnection connection, IRabbitMqHostConfiguration configuration, IRabbitMqHostTopology hostTopology,
                                         string description, CancellationToken cancellationToken)
            : base(cancellationToken)
        {
            _connection = connection;

            Description = description;
            HostAddress = configuration.HostAddress;

            PublisherConfirmation = configuration.PublisherConfirmation;
            BatchSettings         = configuration.BatchSettings;

            Topology = hostTopology;

            StopTimeout = TimeSpan.FromSeconds(30);

            _executor = new ChannelExecutor(1);

            connection.ConnectionShutdown += OnConnectionShutdown;
        }
Ejemplo n.º 15
0
        public RabbitMqHost(IRabbitMqHostConfiguration hostConfiguration, IRabbitMqHostTopology hostTopology)
            : base(hostConfiguration, hostTopology)
        {
            _hostConfiguration = hostConfiguration;
            _hostTopology      = hostTopology;

            ConnectionRetryPolicy = Retry.CreatePolicy(x =>
            {
                x.Handle <RabbitMqConnectionException>();

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

            ConnectionContextSupervisor = new RabbitMqConnectionContextSupervisor(hostConfiguration, hostTopology);

            var cacheSettings = new CacheSettings(SendEndpointCacheDefaults.Capacity, SendEndpointCacheDefaults.MinAge, SendEndpointCacheDefaults.MaxAge);

            var cache = new GreenCache <CachedSendTransport>(cacheSettings);

            _index = cache.AddIndex("key", x => x.Address);
        }
Ejemplo n.º 16
0
 public RabbitMqConnectionCache(RabbitMqHostSettings settings, IRabbitMqHostTopology topology)
     : base(new ConnectionContextFactory(settings, topology))
 {
     _description = settings.ToDebugString();
 }
Ejemplo n.º 17
0
 public DelayedExchangeMessageScheduler(ISendEndpointProvider sendEndpointProvider, IRabbitMqHostTopology topology, Uri hostAddress)
 {
     _sendEndpointProvider = sendEndpointProvider;
     _topology             = topology;
     _hostAddress          = hostAddress;
 }
 public DelayedExchangeScheduleMessageProvider(ISendEndpointProvider sendEndpointProvider, IRabbitMqHostTopology topology)
 {
     _sendEndpointProvider = sendEndpointProvider;
     _topology             = topology;
 }
Ejemplo n.º 19
0
 public RabbitMqConnectionContext(IConnection connection, RabbitMqHostSettings hostSettings, IRabbitMqHostTopology topology, string description, ITaskSupervisor supervisor)
     : this(connection, hostSettings, description, supervisor.CreateParticipant($"{TypeMetadataCache<RabbitMqConnectionContext>.ShortName} - {description}"))
 {
     Topology = topology;
 }
 public RabbitMqConnectionContextSupervisor(IRabbitMqHostConfiguration configuration, IRabbitMqHostTopology hostTopology)
     : base(new ConnectionContextFactory(configuration, hostTopology))
 {
     _description = configuration.Description;
 }
Ejemplo n.º 21
0
 public RabbitMqHost(IRabbitMqHostConfiguration hostConfiguration, IRabbitMqHostTopology hostTopology)
     : base(hostConfiguration, hostTopology)
 {
     _hostConfiguration = hostConfiguration;
     Topology           = hostTopology;
 }