Пример #1
0
        public LinkTopology(LinkConfiguration configuration, ILinkChannel channel, ILinkTopologyHandler handler,
            bool once)
        {
            if (configuration == null)
                throw new ArgumentNullException(nameof(configuration));

            if (channel == null)
                throw new ArgumentNullException(nameof(channel));

            if (handler == null)
                throw new ArgumentNullException(nameof(handler));

            _configuration = configuration;
            _logger = _configuration.LoggerFactory.CreateLogger($"{GetType().Name}({Id:D})");

            if (_logger == null)
                throw new ArgumentException("Cannot create logger", nameof(configuration.LoggerFactory));

            _handler = handler;
            _isOnce = once;

            _disposedCancellationSource = new CancellationTokenSource();
            _disposedCancellation = _disposedCancellationSource.Token;

            Channel = channel;
            Channel.Disposed += ChannelOnDisposed;
            Channel.Ready += ChannelOnReady;

            _logger.Debug($"Created(channelId: {Channel.Id}, once: {once})");

#pragma warning disable 4014
            ScheduleConfiguration(false);
#pragma warning restore 4014           
        }
Пример #2
0
        public LinkChannel(LinkConfiguration configuration, ILinkConnection connection)
        {
            if (configuration == null)
                throw new ArgumentNullException(nameof(configuration));

            if (connection == null)
                throw new ArgumentNullException(nameof(connection));

            _configuration = configuration;
            _logger = _configuration.LoggerFactory.CreateLogger($"{GetType().Name}({Id:D})");

            if (_logger == null)
                throw new ArgumentException("Cannot create logger", nameof(configuration.LoggerFactory));

            _disposedCancellationSource = new CancellationTokenSource();
            _disposedCancellation = _disposedCancellationSource.Token;

            Connection = connection;

            Connection.Disposed += ConnectionOnDisposed;
            Connection.Connected += ConnectionOnConnected;

            _logger.Debug($"Created(connectionId: {Connection.Id:D})");

            ScheduleReopen(false);
        }
Пример #3
0
        public ILinkRegistryNeededConfiguration <D> Link <D>(D listener)
        {
            LinkConfiguration <D> linkConfiguration = linkController.CreateLinkConfiguration(listener);

            AddBeanConfiguration(linkConfiguration);
            return(linkConfiguration);
        }
Пример #4
0
        public ILinkRegistryNeededConfiguration Link(Object listener, String methodName)
        {
            LinkConfiguration <Object> linkConfiguration = linkController.CreateLinkConfiguration(listener, methodName);

            AddBeanConfiguration(linkConfiguration);
            return(linkConfiguration);
        }
Пример #5
0
        public ILinkRegistryNeededConfiguration Link(IBeanConfiguration listenerBean)
        {
            LinkConfiguration <Object> linkConfiguration = linkController.CreateLinkConfiguration(listenerBean, null);

            AddBeanConfiguration(linkConfiguration);
            return(linkConfiguration);
        }
Пример #6
0
        public ILinkRegistryNeededConfiguration Link(String listenerBeanName)
        {
            LinkConfiguration <Object> linkConfiguration = linkController.CreateLinkConfiguration(listenerBeanName, (String)null);

            AddBeanConfiguration(linkConfiguration);
            return(linkConfiguration);
        }
 public LinkConsumerConfigurationBuilder(LinkConfiguration linkConfiguration)
 {
     Configuration.PrefetchCount = linkConfiguration.ConsumerPrefetchCount;
     Configuration.AutoAck = linkConfiguration.ConsumerAutoAck;
     Configuration.CancelOnHaFailover = linkConfiguration.ConsumerCancelOnHaFailover;
     Configuration.GetMessageTimeout = linkConfiguration.ConsumerGetMessageTimeout;
     Configuration.MessageSerializer = linkConfiguration.MessageSerializer;
 }
 public LinkProducerConfigurationBuilder(LinkConfiguration linkConfiguration)
 {
     Configuration.ConfirmsMode = linkConfiguration.ProducerConfirmsMode;
     Configuration.MessageProperties = linkConfiguration.ProducerMessageProperties;
     Configuration.PublishTimeout = linkConfiguration.ProducerPublishTimeout;
     Configuration.MessageSerializer = linkConfiguration.MessageSerializer;
     Configuration.SetUserId = linkConfiguration.ProducerSetUserId;
     Configuration.MessageIdGenerator = linkConfiguration.ProducerMessageIdGenerator;
 }
Пример #9
0
        public Link(string connectionString, Action<ILinkConfigurationBuilder> config = null)
        {
            if (string.IsNullOrWhiteSpace(connectionString))
                throw new ArgumentNullException(nameof(connectionString));

            var configBuilder = new LinkConfigurationBuilder();
            config?.Invoke(configBuilder);

            _configuration = configBuilder.Configuration;
            _configuration.ConnectionString = connectionString;

            _connection = new LinkConnection(_configuration);
        }
Пример #10
0
        public LinkConnection(LinkConfiguration configuration) : base(LinkConnectionState.Init)
        {
            _configuration = configuration;

            _logger = _configuration.LoggerFactory.CreateLogger($"{GetType().Name}({Id:D})")
                      ?? throw new ArgumentException("Cannot create logger", nameof(configuration.LoggerFactory));

            _connectionFactory = new LinkConnectionFactory(
                _configuration.ConnectionName,
                _configuration.AppId,
                _configuration.ConnectionString,
                _configuration.Timeout,
                _configuration.UseBackgroundThreadsForConnection
                );

            _disposeCts          = new CancellationTokenSource();
            _disposeCancellation = _disposeCts.Token;

            _logger.Debug($"Created ( name: {_configuration.ConnectionName})");
            if (_configuration.AutoStart)
            {
                Initialize();
            }
        }
Пример #11
0
 /// <summary>
 ///     Creates new <see cref="Link" /> instance
 /// </summary>
 public Link(LinkConfiguration configuration)
 {
     _configuration = configuration;
     _connection    = new LinkConnection(_configuration);
 }