public TransportInfrastructure(ReadOnlySettings settings)
        {
            configuration = new TransportConfiguration(settings);

            try
            {
                sqsClient = configuration.SqsClientFactory();
            }
            catch (AmazonClientException e)
            {
                var message = "Unable to configure the SQS client. Make sure the environment variables for AWS_REGION, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set or the client factory configures the created client accordingly";
                Logger.Error(message, e);
                throw new Exception(message, e);
            }

            try
            {
                if (!string.IsNullOrEmpty(settings.GetOrDefault <string>(SettingsKeys.S3BucketForLargeMessages)))
                {
                    s3Client = configuration.S3ClientFactory();
                }
            }
            catch (AmazonClientException e)
            {
                var message = "Unable to configure the S3 client. Make sure the environment variables for AWS_REGION, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set or the client factory configures the created client accordingly";
                Logger.Error(message, e);
                throw new Exception(message, e);
            }

            queueUrlCache = new QueueUrlCache(sqsClient);
        }
 public TransportMessage SendRawAndReceiveMessage(string rawMessageString)
 {
     return(SendAndReceiveCore(() =>
     {
         SqsClient.SendMessage(QueueUrlCache.GetQueueUrl(Address), rawMessageString);
     }));
 }
Beispiel #3
0
        private void SendMessage(string message, SendOptions sendOptions)
        {
            var delayDeliveryBy = TimeSpan.MaxValue;

            if (sendOptions.DelayDeliveryWith.HasValue)
            {
                delayDeliveryBy = sendOptions.DelayDeliveryWith.Value;
            }
            else
            {
                if (sendOptions.DeliverAt.HasValue)
                {
                    delayDeliveryBy = sendOptions.DeliverAt.Value - DateTime.UtcNow;
                }
            }

            var sendMessageRequest = new SendMessageRequest(QueueUrlCache.GetQueueUrl(sendOptions.Destination), message);

            // There should be no need to check if the delay time is greater than the maximum allowed
            // by SQS (15 minutes); the call to AWS will fail with an appropriate exception if the limit is exceeded.
            if (delayDeliveryBy != TimeSpan.MaxValue)
            {
                sendMessageRequest.DelaySeconds = Math.Max(0, (int)delayDeliveryBy.TotalSeconds);
            }

            SqsClient.SendMessage(sendMessageRequest);
        }
        public TransportInfrastructure(SettingsHolder settings)
        {
            configuration = new ConnectionConfiguration(settings);

            sqsClient = AwsClientFactory.CreateSqsClient(configuration);
            s3Client  = AwsClientFactory.CreateS3Client(configuration);

            queueUrlCache = new QueueUrlCache(sqsClient);
        }
        public TransportInfrastructure(ReadOnlySettings settings)
        {
            configuration = new TransportConfiguration(settings);

            sqsClient = configuration.SqsClientFactory();
            s3Client  = configuration.S3ClientFactory();

            queueUrlCache = new QueueUrlCache(sqsClient);
        }
        public void CreateQueue()
        {
            Creator.CreateQueueIfNecessary(Address, "");

            try
            {
                SqsClient.PurgeQueue(QueueUrlCache.GetQueueUrl(Address));
            }
            catch (PurgeQueueInProgressException)
            {
            }
        }
Beispiel #7
0
 public MessageDispatcher(TransportConfiguration configuration, IAmazonS3 s3Client, IAmazonSQS sqsClient, QueueUrlCache queueUrlCache)
 {
     this.configuration = configuration;
     this.s3Client      = s3Client;
     this.sqsClient     = sqsClient;
     this.queueUrlCache = queueUrlCache;
     serializerStrategy = configuration.UseV1CompatiblePayload ? SimpleJson.PocoJsonSerializerStrategy : ReducedPayloadSerializerStrategy.Instance;
 }
 public QueueCreator(TransportConfiguration configuration, IAmazonS3 s3Client, IAmazonSQS sqsClient, QueueUrlCache queueUrlCache)
 {
     this.configuration = configuration;
     this.s3Client      = s3Client;
     this.sqsClient     = sqsClient;
     this.queueUrlCache = queueUrlCache;
 }
Beispiel #9
0
 public MessagePump(TransportConfiguration configuration, IAmazonS3 s3Client, IAmazonSQS sqsClient, QueueUrlCache queueUrlCache)
 {
     this.configuration = configuration;
     this.s3Client      = s3Client;
     this.sqsClient     = sqsClient;
     this.queueUrlCache = queueUrlCache;
     awsEndpointUrl     = sqsClient.Config.DetermineServiceURL();
 }
        public MessageDispatcher(TransportConfiguration configuration, IAmazonS3 s3Client, IAmazonSQS sqsClient, QueueUrlCache queueUrlCache)
        {
            this.configuration = configuration;
            this.s3Client      = s3Client;
            this.sqsClient     = sqsClient;
            this.queueUrlCache = queueUrlCache;

            jsonSerializerSettings = new JsonSerializerSettings
            {
                ContractResolver = configuration.UseV1CompatiblePayload ? new DefaultContractResolver() : new ReducedPayloadContractResolver()
            };
        }
Beispiel #11
0
 public MessagePump(ConnectionConfiguration configuration, IAmazonS3 s3Client, IAmazonSQS sqsClient, QueueUrlCache queueUrlCache)
 {
     this.configuration = configuration;
     this.s3Client      = s3Client;
     this.sqsClient     = sqsClient;
     this.queueUrlCache = queueUrlCache;
 }