/// <summary>
        /// Constructs the transport with the specified settings
        /// </summary>
        public AmazonSQSTransport(string inputQueueAddress, AWSCredentials credentials, AmazonSQSConfig amazonSqsConfig, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory, AmazonSQSTransportOptions options = null)
        {
            if (rebusLoggerFactory == null)
            {
                throw new ArgumentNullException(nameof(rebusLoggerFactory));
            }

            _log = rebusLoggerFactory.GetLogger <AmazonSQSTransport>();

            if (inputQueueAddress != null)
            {
                if (inputQueueAddress.Contains("/") && !Uri.IsWellFormedUriString(inputQueueAddress, UriKind.Absolute))
                {
                    var message = $"The input queue address '{inputQueueAddress}' is not valid - please either use a simple queue name (eg. 'my-queue') or a full URL for the queue endpoint (e.g. 'https://sqs.eu-central-1.amazonaws.com/234234234234234/somqueue').";

                    throw new ArgumentException(message, nameof(inputQueueAddress));
                }
            }

            Address = inputQueueAddress;

            _credentials      = credentials ?? throw new ArgumentNullException(nameof(credentials));
            _amazonSqsConfig  = amazonSqsConfig ?? throw new ArgumentNullException(nameof(amazonSqsConfig));
            _asyncTaskFactory = asyncTaskFactory;
            _options          = options ?? new AmazonSQSTransportOptions();
        }
Пример #2
0
        /// <summary>
        /// Constructs the transport with the specified settings
        /// </summary>
        public AmazonSqsTransport(string inputQueueAddress, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory, AmazonSQSTransportOptions options, IRebusTime rebusTime)
        {
            if (rebusLoggerFactory == null)
            {
                throw new ArgumentNullException(nameof(rebusLoggerFactory));
            }

            _options          = options ?? throw new ArgumentNullException(nameof(options));
            _rebusTime        = rebusTime ?? throw new ArgumentNullException(nameof(rebusTime));
            _asyncTaskFactory = asyncTaskFactory ?? throw new ArgumentNullException(nameof(asyncTaskFactory));
            _log = rebusLoggerFactory.GetLogger <AmazonSqsTransport>();

            if (inputQueueAddress != null)
            {
                if (inputQueueAddress.Contains("/") && !Uri.IsWellFormedUriString(inputQueueAddress, UriKind.Absolute))
                {
                    var message = $"The input queue address '{inputQueueAddress}' is not valid - please either use a simple queue name (eg. 'my-queue') or a full URL for the queue endpoint (e.g. 'https://sqs.eu-central-1.amazonaws.com/234234234234234/somqueue').";

                    throw new ArgumentException(message, nameof(inputQueueAddress));
                }
            }

            Address = inputQueueAddress;

            _log.Info("Initializing SQS client");

            _client = _options.ClientFactory();
        }
Пример #3
0
        /// <summary>
        /// Constructs the transport with the specified settings
        /// </summary>
        public AmazonSqsTransport(string inputQueueAddress, AWSCredentials credentials, AmazonSQSConfig amazonSqsConfig, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory, AmazonSQSTransportOptions options = null)
        {
            if (credentials == null)
            {
                throw new ArgumentNullException(nameof(credentials));
            }
            if (amazonSqsConfig == null)
            {
                throw new ArgumentNullException(nameof(amazonSqsConfig));
            }
            if (rebusLoggerFactory == null)
            {
                throw new ArgumentNullException(nameof(rebusLoggerFactory));
            }

            Address = inputQueueAddress;


            _log = rebusLoggerFactory.GetLogger <AmazonSqsTransport>();

            if (Address != null)
            {
                if (Address.Contains("/") && !Uri.IsWellFormedUriString(Address, UriKind.Absolute))
                {
                    throw new ArgumentException(
                              "You could either have a simple queue name without slash (eg. \"inputqueue\") - or a complete URL for the queue endpoint. (eg. \"https://sqs.eu-central-1.amazonaws.com/234234234234234/somqueue\")",
                              nameof(inputQueueAddress));
                }
            }

            _credentials      = credentials;
            _amazonSqsConfig  = amazonSqsConfig;
            _asyncTaskFactory = asyncTaskFactory;
            _serializer       = new AmazonSqsTransportMessageSerializer();
            _transportOptions = options ?? new AmazonSQSTransportOptions();
        }
Пример #4
0
 /// <summary>
 /// Constructs the transport with the specified settings
 /// </summary>
 public AmazonSqsTransport(string inputQueueAddress, string accessKeyId, string secretAccessKey, AmazonSQSConfig amazonSqsConfig, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory, AmazonSQSTransportOptions options = null)
     : this(inputQueueAddress, Credentials(accessKeyId, secretAccessKey), amazonSqsConfig, rebusLoggerFactory, asyncTaskFactory, options)
 {
 }