public AzureServiceBusQueue(AzureServiceBusQueueOptions <T> options) : base(options)
        {
            if (String.IsNullOrEmpty(options.ConnectionString))
            {
                throw new ArgumentException("ConnectionString is required.");
            }

            if (options.Name.Length > 260)
            {
                throw new ArgumentException("Queue name must be set and be less than 260 characters.");
            }

            if (options.WorkItemTimeout > TimeSpan.FromMinutes(5))
            {
                throw new ArgumentException("The maximum WorkItemTimeout value for is 5 minutes; the default value is 1 minute.");
            }

            if (options.AutoDeleteOnIdle.HasValue && options.AutoDeleteOnIdle < TimeSpan.FromMinutes(5))
            {
                throw new ArgumentException("The minimum AutoDeleteOnIdle duration is 5 minutes.");
            }

            if (options.DuplicateDetectionHistoryTimeWindow.HasValue && (options.DuplicateDetectionHistoryTimeWindow < TimeSpan.FromSeconds(20.0) || options.DuplicateDetectionHistoryTimeWindow > TimeSpan.FromDays(7.0)))
            {
                throw new ArgumentException("The minimum DuplicateDetectionHistoryTimeWindow duration is 20 seconds and maximum is 7 days.");
            }

            if (options.UserMetadata != null && options.UserMetadata.Length > 260)
            {
                throw new ArgumentException("Queue UserMetadata must be less than 1024 characters.");
            }

            _namespaceManager = NamespaceManager.CreateFromConnectionString(options.ConnectionString);
        }
Пример #2
0
        public AzureServiceBusQueue(AzureServiceBusQueueOptions <T> options) : base(options)
        {
            if (String.IsNullOrWhiteSpace(options.ConnectionString))
            {
                throw new ArgumentException($"{nameof(options.ConnectionString)} is required.");
            }

            if (String.IsNullOrWhiteSpace(options.SubscriptionId))
            {
                throw new ArgumentException($"{nameof(options.SubscriptionId)} is required.");
            }

            if (options.Name.Length > 260)
            {
                throw new ArgumentException("Queue name must be set and be less than 260 characters.");
            }

            if (options.WorkItemTimeout > TimeSpan.FromMinutes(5))
            {
                throw new ArgumentException("The maximum WorkItemTimeout value for is 5 minutes; the default value is 1 minute.");
            }

            if (options.AutoDeleteOnIdle.HasValue && options.AutoDeleteOnIdle < TimeSpan.FromMinutes(5))
            {
                throw new ArgumentException("The minimum AutoDeleteOnIdle duration is 5 minutes.");
            }

            if (options.DuplicateDetectionHistoryTimeWindow.HasValue && (options.DuplicateDetectionHistoryTimeWindow < TimeSpan.FromSeconds(20.0) || options.DuplicateDetectionHistoryTimeWindow > TimeSpan.FromDays(7.0)))
            {
                throw new ArgumentException("The minimum DuplicateDetectionHistoryTimeWindow duration is 20 seconds and maximum is 7 days.");
            }

            // todo: usermetadata not found in the new lib
            if (options.UserMetadata != null && options.UserMetadata.Length > 260)
            {
                throw new ArgumentException("Queue UserMetadata must be less than 260 characters.");
            }

            _messageReceiver = new MessageReceiver(_options.ConnectionString, _options.Name);
        }