internal ServiceBusConnection(ServiceBusScaleoutOptions options, ILogger logger, TimeSpan errorBackOffAmount, TimeSpan defaultReadTimeout, TimeSpan errorReadTimeout, TimeSpan retryDelay)
        {
            RetryDelay         = retryDelay;
            ErrorReadTimeout   = errorReadTimeout;
            DefaultReadTimeout = defaultReadTimeout;
            ErrorBackOffAmount = errorBackOffAmount;

            _logger           = logger;
            _connectionString = options.BuildConnectionString();

            try
            {
                _namespaceManager = NamespaceManager.CreateFromConnectionString(_connectionString);
                _factory          = MessagingFactory.CreateFromConnectionString(_connectionString);

                if (options.RetryPolicy != null)
                {
                    _factory.RetryPolicy = options.RetryPolicy;
                }
                else
                {
                    _factory.RetryPolicy = RetryExponential.Default;
                }
            }
            catch (ConfigurationException)
            {
                _logger.LogError("The configured Service Bus connection string contains an invalid property. Check the exception details for more information.");
                throw;
            }

            _backoffTime             = options.BackoffTime;
            _idleSubscriptionTimeout = options.IdleSubscriptionTimeout;
            _options = options;
        }
        public ServiceBusConnectionContext(ServiceBusScaleoutOptions options,
                                           IList <string> topicNames,
                                           ILogger logger,
                                           Action <int, IEnumerable <BrokeredMessage> > handler,
                                           Action <int, Exception> errorHandler,
                                           Action <int> openStream)
        {
            if (topicNames == null)
            {
                throw new ArgumentNullException("topicNames");
            }

            _options = options;

            _subscriptions = new SubscriptionContext[topicNames.Count];
            _topicClients  = new TopicClient[topicNames.Count];

            _logger = logger;

            TopicNames   = topicNames;
            Handler      = handler;
            ErrorHandler = errorHandler;
            OpenStream   = openStream;

            TopicClientsLock  = new object();
            SubscriptionsLock = new object();
        }
 public ServiceBusConnection(ServiceBusScaleoutOptions options, ILogger logger)
     : this(options, logger, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(10))
 {
 }