Esempio n. 1
0
        /// <summary> Init the factory.</summary>
        public virtual void Init(IProviderConfiguration config, string providerName, Logger logger, IServiceProvider serviceProvider)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (!config.Properties.TryGetValue(DataConnectionStringPropertyName, out dataConnectionString))
            {
                throw new ArgumentException(string.Format("{0} property not set", DataConnectionStringPropertyName));
            }
            if (!config.Properties.TryGetValue(DeploymentIdPropertyName, out deploymentId))
            {
                throw new ArgumentException(string.Format("{0} property not set", DeploymentIdPropertyName));
            }

            cacheSize = SimpleQueueAdapterCache.ParseSize(config, CacheSizeDefaultValue);

            numQueues = config.GetIntProperty(NumQueuesPropertyName, NumQueuesDefaultValue);

            this.providerName = providerName;
            streamQueueMapper = new HashRingBasedStreamQueueMapper(numQueues, providerName);
            adapterCache      = new SimpleQueueAdapterCache(cacheSize, logger);
            if (StreamFailureHandlerFactory == null)
            {
                StreamFailureHandlerFactory =
                    qid => Task.FromResult <IStreamFailureHandler>(new NoOpStreamDeliveryFailureHandler(false));
            }
        }
Esempio n. 2
0
        /// <summary> Init the factory.</summary>
        public virtual void Init(IProviderConfiguration config, string providerName, Logger logger, IServiceProvider serviceProvider)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (!config.Properties.TryGetValue(DataConnectionStringPropertyName, out dataConnectionString))
            {
                throw new ArgumentException(String.Format("{0} property not set", DataConnectionStringPropertyName));
            }
            if (!config.Properties.TryGetValue(DeploymentIdPropertyName, out deploymentId))
            {
                throw new ArgumentException(String.Format("{0} property not set", DeploymentIdPropertyName));
            }

            cacheSize = SimpleQueueAdapterCache.ParseSize(config, CacheSizeDefaultValue);

            string numQueuesString;

            numQueues = NumQueuesDefaultValue;
            if (config.Properties.TryGetValue(NumQueuesPropertyName, out numQueuesString))
            {
                if (!int.TryParse(numQueuesString, out numQueues))
                {
                    throw new ArgumentException(String.Format("{0} invalid.  Must be int", NumQueuesPropertyName));
                }
            }

            this.providerName = providerName;
            streamQueueMapper = new HashRingBasedStreamQueueMapper(numQueues, providerName);
            adapterCache      = new SimpleQueueAdapterCache(cacheSize, logger);
        }
Esempio n. 3
0
        /// <summary> Init the factory.</summary>
        public virtual void Init(IProviderConfiguration config, string providerName, Logger logger, IServiceProvider serviceProvider)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (!config.Properties.TryGetValue(DATA_CONNECTION_STRING, out dataConnectionString))
            {
                throw new ArgumentException(String.Format("{0} property not set", DATA_CONNECTION_STRING));
            }
            if (!config.Properties.TryGetValue(DEPLOYMENT_ID, out deploymentId))
            {
                throw new ArgumentException(String.Format("{0} property not set", DEPLOYMENT_ID));
            }

            cacheSize = SimpleQueueAdapterCache.ParseSize(config, DEFAULT_CACHE_SIZE);

            string numQueuesString;

            numQueues = DEFAULT_NUM_QUEUES;
            if (config.Properties.TryGetValue(NUM_QUEUES_PARAM, out numQueuesString))
            {
                if (!int.TryParse(numQueuesString, out numQueues))
                {
                    throw new ArgumentException(String.Format("{0} invalid.  Must be int", NUM_QUEUES_PARAM));
                }
            }

            this.providerName = providerName;
            streamQueueMapper = new HashRingBasedStreamQueueMapper(numQueues, providerName);
            adapterCache      = new SimpleQueueAdapterCache(cacheSize, logger);
        }
        /// <summary> Init the factory.</summary>
        public virtual void Init(IProviderConfiguration config, string providerName, Logger logger, IServiceProvider serviceProvider)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (!config.Properties.TryGetValue(AzureQueueAdapterConstants.DataConnectionStringPropertyName, out dataConnectionString))
            {
                throw new ArgumentException($"{AzureQueueAdapterConstants.DataConnectionStringPropertyName} property not set");
            }
            if (!config.Properties.TryGetValue(AzureQueueAdapterConstants.DeploymentIdPropertyName, out deploymentId))
            {
                throw new ArgumentException($"{AzureQueueAdapterConstants.DeploymentIdPropertyName} property not set");
            }
            string messageVisibilityTimeoutRaw;

            if (config.Properties.TryGetValue(AzureQueueAdapterConstants.MessageVisibilityTimeoutPropertyName, out messageVisibilityTimeoutRaw))
            {
                TimeSpan messageVisibilityTimeoutTemp;
                if (!TimeSpan.TryParse(messageVisibilityTimeoutRaw, out messageVisibilityTimeoutTemp))
                {
                    throw new ArgumentException(
                              $"Failed to parse {AzureQueueAdapterConstants.MessageVisibilityTimeoutPropertyName} value '{messageVisibilityTimeoutRaw}' as a TimeSpan");
                }

                messageVisibilityTimeout = messageVisibilityTimeoutTemp;
            }
            else
            {
                messageVisibilityTimeout = null;
            }

            cacheSize          = SimpleQueueAdapterCache.ParseSize(config, AzureQueueAdapterConstants.CacheSizeDefaultValue);
            this.loggerFactory = serviceProvider.GetRequiredService <ILoggerFactory>();
            string numQueuesString;

            numQueues = AzureQueueAdapterConstants.NumQueuesDefaultValue;
            if (config.Properties.TryGetValue(AzureQueueAdapterConstants.NumQueuesPropertyName, out numQueuesString))
            {
                if (!int.TryParse(numQueuesString, out numQueues))
                {
                    throw new ArgumentException($"{AzureQueueAdapterConstants.NumQueuesPropertyName} invalid.  Must be int");
                }
            }

            this.providerName = providerName;
            streamQueueMapper = new HashRingBasedStreamQueueMapper(numQueues, providerName);
            adapterCache      = new SimpleQueueAdapterCache(cacheSize, logger);
            if (StreamFailureHandlerFactory == null)
            {
                StreamFailureHandlerFactory =
                    qid => Task.FromResult <IStreamFailureHandler>(new NoOpStreamDeliveryFailureHandler());
            }

            this.SerializationManager = serviceProvider.GetRequiredService <SerializationManager>();
            this.adaptorFactory       = () => ActivatorUtilities.GetServiceOrCreateInstance <TDataAdapter>(serviceProvider);
        }
Esempio n. 5
0
        /// <summary> Init the factory.</summary>
        public virtual void Init(IProviderConfiguration config, string providerName, Logger logger, IServiceProvider serviceProvider)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (!config.Properties.TryGetValue(DataConnectionStringPropertyName, out dataConnectionString))
            {
                throw new ArgumentException(String.Format("{0} property not set", DataConnectionStringPropertyName));
            }
            if (!config.Properties.TryGetValue(DeploymentIdPropertyName, out deploymentId))
            {
                throw new ArgumentException(String.Format("{0} property not set", DeploymentIdPropertyName));
            }
            string messageVisibilityTimeoutRaw;

            if (config.Properties.TryGetValue(MessageVisibilityTimeoutPropertyName, out messageVisibilityTimeoutRaw))
            {
                TimeSpan messageVisibilityTimeoutTemp;
                if (!TimeSpan.TryParse(messageVisibilityTimeoutRaw, out messageVisibilityTimeoutTemp))
                {
                    throw new ArgumentException(String.Format("Failed to parse {0} value '{1}' as a TimeSpan",
                                                              MessageVisibilityTimeoutPropertyName, messageVisibilityTimeoutRaw));
                }

                messageVisibilityTimeout = messageVisibilityTimeoutTemp;
            }
            else
            {
                messageVisibilityTimeout = null;
            }

            cacheSize = SimpleQueueAdapterCache.ParseSize(config, CacheSizeDefaultValue);

            string numQueuesString;

            numQueues = NumQueuesDefaultValue;
            if (config.Properties.TryGetValue(NumQueuesPropertyName, out numQueuesString))
            {
                if (!int.TryParse(numQueuesString, out numQueues))
                {
                    throw new ArgumentException(String.Format("{0} invalid.  Must be int", NumQueuesPropertyName));
                }
            }

            this.providerName = providerName;
            streamQueueMapper = new HashRingBasedStreamQueueMapper(numQueues, providerName);
            adapterCache      = new SimpleQueueAdapterCache(cacheSize, logger);
            if (StreamFailureHandlerFactory == null)
            {
                StreamFailureHandlerFactory =
                    qid => Task.FromResult <IStreamFailureHandler>(new NoOpStreamDeliveryFailureHandler(false));
            }
        }
        public void Init(IProviderConfiguration config, string providerName, Logger logger, IServiceProvider serviceProvider)
        {
            _config       = new RabbitMQStreamProviderConfig(config);
            _providerName = providerName;
            _logger       = logger;

            _mapper.Init(logger);

            _cacheSize    = SimpleQueueAdapterCache.ParseSize(config, 4096);
            _adapterCache = new SimpleQueueAdapterCache(_cacheSize, logger);

            _streamQueueMapper = new HashRingBasedStreamQueueMapper(_config.NumQueues, _providerName);

            if (StreamFailureHandlerFactory == null)
            {
                StreamFailureHandlerFactory =
                    qid => Task.FromResult <IStreamFailureHandler>(new NoOpStreamDeliveryFailureHandler(false));
            }
        }
Esempio n. 7
0
        public void Init(IProviderConfiguration config, string providerName, IServiceProvider serviceProvider)
        {
            _config       = serviceProvider.GetRequiredService <RabbitMQStreamProviderOptions>();
            _providerName = providerName;
            _loggeFactory = serviceProvider.GetRequiredService <ILoggerFactory>();

            _mapper = serviceProvider.GetRequiredService <IRabbitMQMapper>();
            _mapper.Init();

            _cacheSize    = SimpleQueueAdapterCache.ParseSize(config, 4096);
            _adapterCache = new SimpleQueueAdapterCache(_cacheSize, providerName, _loggeFactory);

            _streamQueueMapper = new HashRingBasedStreamQueueMapper(_config.NumberOfQueues, _providerName);

            if (StreamFailureHandlerFactory == null)
            {
                StreamFailureHandlerFactory =
                    qid => Task.FromResult <IStreamFailureHandler>(new NoOpStreamDeliveryFailureHandler(false));
            }
        }
Esempio n. 8
0
        public void Init(IProviderConfiguration config, string providerName, Logger logger, IServiceProvider serviceProvider)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _configuration = new RabbitMQStreamProviderConfiguration(config);
            _logger        = logger;
            _providerName  = providerName;

            _cacheSize = SimpleQueueAdapterCache.ParseSize(config, 4096);

            _streamQueueMapper = new HashRingBasedStreamQueueMapper(_configuration.NumQueues, providerName);
            _adapterCache      = new SimpleQueueAdapterCache(_cacheSize, logger);

            if (StreamFailureHandlerFactory == null)
            {
                StreamFailureHandlerFactory =
                    qid => Task.FromResult <IStreamFailureHandler>(new NoOpStreamDeliveryFailureHandler(false));
            }

            this.SerializationManager = serviceProvider.GetRequiredService <SerializationManager>();
            _adaptorFactory           = () => ActivatorUtilities.GetServiceOrCreateInstance <TDataAdapter>(serviceProvider);
        }
Esempio n. 9
0
        public virtual void Init(IProviderConfiguration config, string providerName, IServiceProvider serviceProvider)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (!config.Properties.TryGetValue(PubSubAdapterConstants.PROJECT_ID, out _projectId))
            {
                throw new ArgumentException($"{PubSubAdapterConstants.PROJECT_ID} property not set");
            }
            if (!config.Properties.TryGetValue(PubSubAdapterConstants.TOPIC_ID, out _topicId))
            {
                throw new ArgumentException($"{PubSubAdapterConstants.TOPIC_ID} property not set");
            }
            if (!config.Properties.TryGetValue(PubSubAdapterConstants.DEPLOYMENT_ID, out _deploymentId))
            {
                throw new ArgumentException($"{PubSubAdapterConstants.DEPLOYMENT_ID} property not set");
            }

            loggerFactory = serviceProvider.GetRequiredService <ILoggerFactory>();

            config.Properties.TryGetValue(PubSubAdapterConstants.CUSTOM_ENDPOINT, out _customEndpoint);

            string deadlineStr;

            if (config.Properties.TryGetValue(PubSubAdapterConstants.DEADLINE, out deadlineStr))
            {
                int seconds;
                if (!int.TryParse(deadlineStr, out seconds))
                {
                    throw new ArgumentException(
                              $"Failed to parse {PubSubAdapterConstants.DEADLINE} value '{deadlineStr}' as a TimeSpan");
                }

                _deadline = TimeSpan.FromSeconds(seconds);

                if (_deadline == TimeSpan.MinValue || _deadline > PubSubAdapterConstants.MAX_DEADLINE)
                {
                    _deadline = PubSubAdapterConstants.MAX_DEADLINE;
                }
            }
            else
            {
                _deadline = null;
            }

            _cacheSize = SimpleQueueAdapterCache.ParseSize(config, PubSubAdapterConstants.CACHE_SIZE_DEFAULT);

            string numSubscriptionsString;

            _numSubscriptions = PubSubAdapterConstants.NUMBER_SUBSCRIPTIONS_DEFAULT;
            if (config.Properties.TryGetValue(PubSubAdapterConstants.NUMBER_SUBSCRIPTIONS, out numSubscriptionsString))
            {
                if (!int.TryParse(numSubscriptionsString, out _numSubscriptions))
                {
                    throw new ArgumentException($"{PubSubAdapterConstants.NUMBER_SUBSCRIPTIONS} invalid.  Must be int");
                }
            }

            _providerName      = providerName;
            _streamQueueMapper = new HashRingBasedStreamQueueMapper(_numSubscriptions, providerName);
            _adapterCache      = new SimpleQueueAdapterCache(_cacheSize, providerName, loggerFactory);
            if (StreamFailureHandlerFactory == null)
            {
                StreamFailureHandlerFactory =
                    qid => Task.FromResult <IStreamFailureHandler>(new NoOpStreamDeliveryFailureHandler());
            }

            SerializationManager = serviceProvider.GetRequiredService <SerializationManager>();
            _adaptorFactory      = () => ActivatorUtilities.GetServiceOrCreateInstance <TDataAdapter>(serviceProvider);
        }