コード例 #1
0
 public SqsQueueDynamoDbCircuitBreaker(IAmazonSQS queueClient, string queueName, int breakerTripQueueSize, ILogger structuredLogger)
 {
     this.structuredLogger = structuredLogger;
     this.breakerTripQueueSize = breakerTripQueueSize;
     this.queueClient = queueClient;
     this.queueName = queueName;
 }
コード例 #2
0
 public void FixtureSetup()
 {
     //_client = SqsTestClientFactory.GetClient();
     // NOTE: This purposely gets an instance of the Fake client directly vs. using the factory, as these
     // tests create a lot of queues that are never really used, so we don't want to actually run it against
     // a "real" SQS instance typically. If we want to, just use the line above instead of the line below.
     client = FakeAmazonSqs.Instance;
     helper = new FakeSqsClientHelper(client);
 }
コード例 #3
0
        public void Subscribe(IAmazonSQS amazonSqsClient, string queueUrl)
        {
            if (!_configured)
            {
                Configure();
            }

            _amazonSNSClient.SubscribeQueue(TopicArn, amazonSqsClient, queueUrl);
        }
コード例 #4
0
ファイル: SnsTopicBase.cs プロジェクト: SamHWhale/JustSaying
        public bool Subscribe(IAmazonSQS amazonSQSClient, SqsQueueBase queue)
        {
            var subscriptionArn = Client.SubscribeQueue(Arn, amazonSQSClient, queue.Url);
            if (!string.IsNullOrEmpty(subscriptionArn))
            {
                return true;
            }

            Log.Info(string.Format("Failed to subscribe Queue to Topic: {0}, Topic: {1}", queue.Arn, Arn));
            return false;
        }
コード例 #5
0
 protected void SetUp()
 {
     _client = Substitute.For<IAmazonSQS>();
     _client.ListQueues(Arg.Any<ListQueuesRequest>())
         .Returns(new ListQueuesResponse() { QueueUrls = new List<string>() { "some-queue-name" } });
     _client.GetQueueAttributes(Arg.Any<GetQueueAttributesRequest>())
         .Returns(new GetQueueAttributesResponse()
         {
             Attributes = new Dictionary<string, string>() { { "QueueArn", "something:some-queue-name" } }
         });
 }
コード例 #6
0
        public ConcurrentSqsReceiver(IAmazonSQS amazonSQSClient, QueueConfiguration queueConfiguration, Func<Message, bool> onReceived,
            Action<Exception, Message> onError, int maxNumberOfMessages = 1, int concurrency = 1)
            : base(amazonSQSClient, queueConfiguration, onReceived, onError, maxNumberOfMessages)
        {
            if (concurrency < 1)
            {
                throw new ArgumentException("Concurrency must be greater than 0", "concurrency");
            }

            _activeTasks = new List<Task>();
            _maximumNumberOfTasks = MaxNumberOfMessages*concurrency;
        }
コード例 #7
0
 public SequentialSQSReceiver(IAmazonSQS amazonSQSClient, QueueConfiguration queueConfiguration, Func<Message, bool> onRecieved, Action<Exception, Message> onError, int maxNumberOfMessages = DefaultNumberOfMessagesToReceiveAtATime)
 {
     if (maxNumberOfMessages > 10 | maxNumberOfMessages < 1)
     {
         throw new ArgumentException("MaxNumberOfMessages must be between 1 and 10", "maxNumberOfMessages");
     }
     
     _amazonSQSClient = amazonSQSClient;
     _queueConfiguration = queueConfiguration;
     MaxNumberOfMessages = maxNumberOfMessages;
     _onRecieved = onRecieved;
     _onError = onError;
 }
コード例 #8
0
        protected override void Given()
        {
            base.Given();

            TopicName = "CustomerCommunication";
            QueueName = "queuename-" + DateTime.Now.Ticks;

            EnableMockedBus();

            Configuration = new MessagingConfig();

            DeleteTopicIfItAlreadyExists(TestEndpoint, TopicName);
            DeleteQueueIfItAlreadyExists(TestEndpoint, QueueName);
            Client = CreateMeABus.DefaultClientFactory().GetSqsClient(RegionEndpoint.EUWest1);
        }
コード例 #9
0
ファイル: SqsPolicy.cs プロジェクト: JonahAcquah/JustSaying
        public static void Save(string sourceArn, string queueArn, string queueUrl, IAmazonSQS client)
        {
            var topicArnWildcard = CreateTopicArnWildcard(sourceArn);
            ActionIdentifier[] actions = { SQSActionIdentifiers.SendMessage };

            Policy sqsPolicy = new Policy()
                .WithStatements(new Statement(Statement.StatementEffect.Allow)
                    .WithPrincipals(Principal.AllUsers)
                    .WithResources(new Resource(queueArn))
                    .WithConditions(ConditionFactory.NewSourceArnCondition(topicArnWildcard))
                    .WithActionIdentifiers(actions));
            SetQueueAttributesRequest setQueueAttributesRequest = new SetQueueAttributesRequest();
            setQueueAttributesRequest.QueueUrl = queueUrl;
            setQueueAttributesRequest.Attributes["Policy"] = sqsPolicy.ToJson();
            client.SetQueueAttributes(setQueueAttributesRequest);
        }
コード例 #10
0
ファイル: SqsClient.cs プロジェクト: sonbua/Mantle
        protected SqsClient(IAwsConfiguration awsConfiguration)
        {
            if (awsConfiguration == null)
                throw new ArgumentNullException("awsConfiguration");

            awsConfiguration.Validate();

            try
            {
                Client = AWSClientFactory.CreateAmazonSQSClient(awsConfiguration.AccessKey, awsConfiguration.SecretKey);
            }
            catch (Exception ex)
            {
                throw new MessagingException(
                    "An error occurred while attempting to access SQS. See inner exception for more details.",
                    ex);
            }
        }
コード例 #11
0
 private Amazon.SQS.Model.UntagQueueResponse CallAWSServiceOperation(IAmazonSQS client, Amazon.SQS.Model.UntagQueueRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Queue Service (SQS)", "UntagQueue");
     try
     {
         #if DESKTOP
         return(client.UntagQueue(request));
         #elif CORECLR
         return(client.UntagQueueAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
コード例 #12
0
        public SQSQueueReceiver(ISQSConfiguration configuration, IAmazonSQS sqs)
        {
            _name            = configuration.Name;
            _queueUrl        = configuration.QueueUrl;
            _maxMessages     = configuration.MaxMessages;
            _autoAcknwoledge = configuration.AutoAcknowledge;

            _sqs = sqs;

            _worker = new Thread(DoStuff);

            _logger = new Lazy <ILogger>(() =>
            {
                try
                {
                    return(LoggerFactory.GetInstance());
                }
                catch
                {
                    return(null);
                }
            });
        }
コード例 #13
0
        protected override void Given()
        {
            LoggerFactory         = new LoggerFactory();
            Sqs                   = Substitute.For <IAmazonSQS>();
            SerialisationRegister = Substitute.For <IMessageSerialisationRegister>();
            Monitor               = Substitute.For <IMessageMonitor>();
            Handler               = Substitute.For <IHandlerAsync <GenericMessage> >();
            LoggerFactory         = Substitute.For <ILoggerFactory>();

            var response = GenerateResponseMessage(MessageTypeString, Guid.NewGuid());

            Sqs.ReceiveMessageAsync(
                Arg.Any <ReceiveMessageRequest>(),
                Arg.Any <CancellationToken>())
            .Returns(
                x => Task.FromResult(response),
                x => Task.FromResult(new ReceiveMessageResponse()));

            DeserialisedMessage = new GenericMessage {
                RaisingComponent = "Component"
            };
            SerialisationRegister.DeserializeMessage(Arg.Any <string>()).Returns(DeserialisedMessage);
        }
コード例 #14
0
ファイル: SqsSource.cs プロジェクト: vkulikov/Alpakka
        public static Source <Message, NotUsed> Create(IAmazonSQS client, string queueUrl, SqsSourceSettings settings = null)
        {
            settings = settings ?? SqsSourceSettings.Default;
            var request = new ReceiveMessageRequest
            {
                QueueUrl              = queueUrl,
                MaxNumberOfMessages   = settings.MaxBatchSize,
                WaitTimeSeconds       = (int)settings.WaitTime.TotalSeconds,
                AttributeNames        = settings.AttributeNames.Select(a => a.Name).ToList(),
                MessageAttributeNames = settings.MessageAttributeNames.Select(a => a.Name).ToList()
            };

            if (settings.VisibilityTimeout.HasValue)
            {
                request.VisibilityTimeout = (int)settings.VisibilityTimeout.Value.TotalSeconds;
            }

            return(Source.Repeat(request)
                   .SelectAsync(settings.Parallelism, req => client.ReceiveMessageAsync(req))
                   .TakeWhile(resp => !settings.CloseOnEmptyReceive || resp.Messages.Count != 0)
                   .SelectMany(resp => resp.Messages)
                   .Buffer(settings.MaxBufferSize, OverflowStrategy.Backpressure));
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: jobairkhan/AwsSqs
        private static async Task SendBatchMessage(IAmazonSQS amazonSqsClient, string queueUrl, int batchSize)
        {
            var request = new SendMessageBatchRequest
            {
                Entries = new List <SendMessageBatchRequestEntry>()
                {
                },
                QueueUrl = queueUrl
            };

            for (var i = 0; i < batchSize; i++)
            {
                request.Entries.Add(CreateNewEntry($"{i + _messageCount}"));
            }


            var response = await amazonSqsClient.SendMessageBatchAsync(request, CancellationToken.None);

            WriteToConsole(response.Successful);
            WriteToConsole(response.Failed);

            Console.ForegroundColor = ConsoleColor.White;
        }
        /// <summary>
        /// Subscribes an existing Amazon SQS queue to an existing Amazon SNS topic.
        /// <para>
        /// The policy applied to the SQS queue is similar to this:
        /// <code>
        /// {
        /// 	"Version" : "2008-10-17",
        /// 	"Statement" : [{
        /// 	    "Sid" : "topic-subscription-arn:aws:sns:us-west-2:599109622955:myTopic",
        /// 		"Effect" : "Allow",
        /// 		"Principal" : {
        /// 			"AWS":["*"]
        /// 		},
        /// 		"Action" : ["sqs:SendMessage"],
        /// 		"Resource":["arn:aws:sqs:us-west-2:599109622955:myQueue"],
        /// 		"Condition" : {
        /// 			"ArnLike":{
        /// 				"aws:SourceArn":["arn:aws:sns:us-west-2:599109622955:myTopic"]
        /// 			}
        /// 		}
        ///     }]
        /// }
        /// </code>
        /// </para>
        /// <para>
        /// There might be a small time period immediately after
        /// subscribing the SQS queue to the SNS topic and updating the SQS queue's
        /// policy, where messages are not able to be delivered to the queue. After a
        /// moment, the new queue policy will propagate and the queue will be able to
        /// receive messages. This delay only occurs immediately after initially
        /// subscribing the queue.
        /// </para>
        /// </summary>
        /// <param name="topicArn">The topic to subscribe to</param>
        /// <param name="sqsClient">The SQS client used to get attributes and set the policy on the SQS queue.</param>
        /// <param name="sqsQueueUrl">The queue to add a subscription to.</param>
        /// <returns>The subscription ARN as returned by Amazon SNS when the queue is 
        /// successfully subscribed to the topic.</returns>
        public string SubscribeQueue(string topicArn, IAmazonSQS sqsClient, string sqsQueueUrl)
        {
            // Get the queue's existing policy and ARN
            var getAttributeResponse = sqsClient.GetQueueAttributes(new GetQueueAttributesRequest()
            {
                AttributeNames = new List<string>() { "All" },
                QueueUrl = sqsQueueUrl
            });

            string sqsQueueArn = getAttributeResponse.QueueARN;

            Policy policy;
            string policyStr = getAttributeResponse.Policy;
            if (string.IsNullOrEmpty(policyStr))
                policy = new Policy();
            else
                policy = Policy.FromJson(policyStr);

            if (!HasSQSPermission(policy, topicArn, sqsQueueArn))
            {
                AddSQSPermission(policy, topicArn, sqsQueueArn);
                sqsClient.SetQueueAttributes(new SetQueueAttributesRequest()
                {
                    QueueUrl = sqsQueueUrl,
                    Attributes = new Dictionary<string, string>() { { "Policy", policy.ToJson() } }
                });
            }

            var subscribeResponse = this.Subscribe(new SubscribeRequest()
            {
                TopicArn = topicArn,
                Protocol = "sqs",
                Endpoint = sqsQueueArn
            });

            return subscribeResponse.SubscriptionArn;
        }
コード例 #17
0
        static async Task Usage(IAmazonSQS client, IAmazonS3 s3Client)
        {
            #region sqs-nativesend-usage

            await SendMessage(
                sqsClient : client,
                queue : "samples-sqs-nativeintegration",
                messageBody : "{Property:'PropertyValue'}",
                headers : new Dictionary <string, string>
            {
                { "NServiceBus.EnclosedMessageTypes", "MessageTypeToSend" },
                { "NServiceBus.MessageId", "99C7320B-A645-4C74-95E8-857EAB98F4F9" }
            }
                )
            .ConfigureAwait(false);

            #endregion

            #region sqs-nativesend-large-usage

            await SendLargeMessage(
                sqsClient : client,
                s3Client : s3Client,
                queue : "samples-sqs-nativeintegration-large",
                s3Prefix : "s3prefix",
                bucketName : "bucketname",
                messageBody : "{Property:'PropertyValue'}",
                headers : new Dictionary <string, string>
            {
                { "NServiceBus.EnclosedMessageTypes", "MessageTypeToSend" },
                { "NServiceBus.MessageId", "99C7320B-A645-4C74-95E8-857EAB98F4F9" }
            }
                )
            .ConfigureAwait(false);

            #endregion
        }
コード例 #18
0
        private void DeleteMessage(IAmazonSQS sqs,
                                   IAmazonS3 s3,
                                   Message message,
                                   SqsTransportMessage sqsTransportMessage,
                                   TransportMessage transportMessage)
        {
            sqs.DeleteMessage(_queueUrl, message.ReceiptHandle);

            if (!String.IsNullOrEmpty(sqsTransportMessage.S3BodyKey))
            {
                // Delete the S3 body asynchronously.
                // We don't really care too much if this call succeeds or fails - if it fails,
                // the S3 bucket lifecycle configuration will eventually delete the message anyway.
                // So, we can get better performance by not waiting around for this call to finish.
                var s3DeleteTask = s3.DeleteObjectAsync(
                    new DeleteObjectRequest
                {
                    BucketName = ConnectionConfiguration.S3BucketForLargeMessages,
                    Key        = ConnectionConfiguration.S3KeyPrefix + transportMessage.Id
                });

                s3DeleteTask.ContinueWith(t =>
                {
                    if (t.Exception != null)
                    {
                        // If deleting the message body from S3 fails, we don't
                        // want the exception to make its way through to the _endProcessMessage below,
                        // as the message has been successfully processed and deleted from the SQS queue
                        // and effectively doesn't exist anymore.
                        // It doesn't really matter, as S3 is configured to delete message body data
                        // automatically after a certain period of time.
                        Logger.Warn("Couldn't delete message body from S3. Message body data will be aged out at a later time.", t.Exception);
                    }
                });
            }
        }
コード例 #19
0
        public static SendMessageBatchResponse SendBatch(IAmazonSQS queueClient, string queueUrl, List <SendMessageBatchRequestEntry> messages)
        {
            var sqsResult = queueClient.SendMessageBatchAsync(queueUrl, messages).Result;

            if (sqsResult.Failed.Any())
            {
                Console.WriteLine($"Failed to insert into SQS: {GetFailureReason(sqsResult.Failed)}.");
                Console.WriteLine("Retrying in 10 seconds");
                Thread.Sleep(TimeSpan.FromSeconds(10));

                var retryMessages = new List <SendMessageBatchRequestEntry>();
                foreach (BatchResultErrorEntry failedMessage in sqsResult.Failed)
                {
                    retryMessages.Add(messages.Single(x => x.Id == failedMessage.Id));
                }

                var retrySqsResult = queueClient.SendMessageBatchAsync(queueUrl, retryMessages).Result;
                if (retrySqsResult.Failed.Any())
                {
                    throw new Exception($"Failed to insert into SQS: {GetFailureReason(retrySqsResult.Failed)}.");
                }
            }
            return(sqsResult);
        }
コード例 #20
0
        public BookQueuePublisher(
            IAmazonSQS queue,
            QueuePublisherConfig queuePublisherConfig)
        {
            _queue = queue;
            _serializerSettings = new JsonSerializerSettings
            {
                Converters = new List <JsonConverter>()
                {
                    new StringEnumConverter()
                }
            };

            var queueName = queuePublisherConfig.QueueNamePrefix + "book-chest-queue";

            _getQueueUrlTask = Task.Run(async() =>
            {
                var request = new GetQueueUrlRequest {
                    QueueName = queueName
                };
                var response = await _queue.GetQueueUrlAsync(request);
                return(response.QueueUrl);
            });
        }
コード例 #21
0
        private static IAmazonSQS GetSqsClient(SqsServiceProviders sqsProviderType, IConfiguration configuration)
        {
            IAmazonSQS sqsClient = null;

            switch (sqsProviderType)
            {
            case SqsServiceProviders.Amazon:
                sqsClient = NativeAwsProvider.GetSqsClient();
                break;

            case SqsServiceProviders.GoAws:
                sqsClient = new GoAws(configuration).GetSqsClient();
                break;

            case SqsServiceProviders.LocalStack:
                sqsClient = new LocalStack(configuration).GetSqsClient();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(sqsProviderType));
            }

            return(sqsClient);
        }
コード例 #22
0
        internal DownloadFileCommand(ArchiveTransferManager manager, string vaultName, string archiveId, string filePath, DownloadOptions options)
        {
            this.manager   = manager;
            this.vaultName = vaultName;
            this.archiveId = archiveId;
            this.filePath  = filePath;
            this.options   = options;

            var credentials   = ((AmazonGlacierClient)this.manager.GlacierClient).GetCredentials();
            var glacierClient = this.manager.GlacierClient as AmazonGlacierClient;

            if (glacierClient == null)
            {
                throw new InvalidOperationException("This can only be called using an AmazonGlacierClient");
            }

            this.snsClient = new AmazonSimpleNotificationServiceClient(credentials, glacierClient.CloneConfig <AmazonSimpleNotificationServiceConfig>());
            this.sqsClient = new AmazonSQSClient(credentials, glacierClient.CloneConfig <AmazonSQSConfig>());

            if (this.options == null)
            {
                this.options = new DownloadOptions();
            }
        }
コード例 #23
0
        public static async Task <SendMessageResponse> SendMessageAsync(
            this IAmazonSQS amazonSqsClient,
            string queueUrl,
            object message,
            Type type,
            int delayInSeconds = 0,
            CancellationToken cancellationToken = default)
        {
            var messageBody = new MessageBody
            {
                Message = JsonConvert.SerializeObject(
                    message,
                    new JsonSerializerSettings
                {
                    Formatting       = Formatting.Indented,
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                }),
                MessageAttributes = new Dictionary <string, MessageAttribute>
                {
                    {
                        "MessageType", new MessageAttribute
                        {
                            Type  = "String",
                            Value = type.Name
                        }
                    }
                }
            };

            return(await amazonSqsClient.SendMessageAsync(new SendMessageRequest
            {
                QueueUrl = queueUrl,
                MessageBody = JsonConvert.SerializeObject(messageBody),
                DelaySeconds = delayInSeconds
            }, cancellationToken));
        }
コード例 #24
0
        static async Task Main()
        {
            _client = new AmazonSQSClient(_serviceRegion);
            var createQueueResponse = await CreateQueue(_client, _queueName);

            string queueUrl = createQueueResponse.QueueUrl;

            Dictionary <string, MessageAttributeValue> messageAttributes = new Dictionary <string, MessageAttributeValue>
            {
                { "Title", new MessageAttributeValue {
                      DataType = "String", StringValue = "The Whistler"
                  } },
                { "Author", new MessageAttributeValue {
                      DataType = "String", StringValue = "John Grisham"
                  } },
                { "WeeksOn", new MessageAttributeValue {
                      DataType = "Number", StringValue = "6"
                  } }
            };

            string messageBody = "Information about current NY Times fiction bestseller for week of 12/11/2016.";

            var sendMsgResponse = await SendMessage(_client, queueUrl, messageBody, messageAttributes);
        }
コード例 #25
0
 public SqsSourceTests(ITestOutputHelper output) : base(output: output)
 {
     this.materializer = Sys.Materializer();
     this.client       = Substitute.For <IAmazonSQS>();
 }
コード例 #26
0
        internal DownloadFileCommand(ArchiveTransferManager manager, string vaultName, string archiveId, string filePath, DownloadOptions options)
        {
            this.manager = manager;
            this.vaultName = vaultName;
            this.archiveId = archiveId;
            this.filePath = filePath;
            this.options = options;

            var glacierClient = this.manager.GlacierClient as AmazonGlacierClient;
            if (glacierClient == null)
                throw new InvalidOperationException("This can only be called using an AmazonGlacierClient");

            this.snsClient = ServiceClientHelpers.CreateServiceFromAnother<AmazonSimpleNotificationServiceClient, AmazonSimpleNotificationServiceConfig>(glacierClient);
            this.sqsClient = ServiceClientHelpers.CreateServiceFromAnother<AmazonSQSClient, AmazonSQSConfig>(glacierClient);

            if (this.options == null)
                this.options = new DownloadOptions();
        }
コード例 #27
0
 public UserOnBoardingService(IAmazonSQS sqs, IUserRepository repository, ISendEmail email)
 {
     _sqs        = sqs;
     _repository = repository;
     _email      = email;
 }
コード例 #28
0
 public DummySqsQueue(Uri uri, IAmazonSQS client) : base(RegionEndpoint.EUWest1, client)
 {
     Uri = uri;
 }
コード例 #29
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;
 }
コード例 #30
0
ファイル: ErrorQueue.cs プロジェクト: jaimalchohan/JustSaying
 public ErrorQueue(string sourceQueueName, IAmazonSQS client)
     : base(sourceQueueName + "_error", client)
 {
     ErrorQueue = null;
 }
コード例 #31
0
ファイル: ErrorQueue.cs プロジェクト: JonahAcquah/JustSaying
 public ErrorQueue(RegionEndpoint region, string sourceQueueName, IAmazonSQS client)
     : base(region, sourceQueueName + "_error", client)
 {
     ErrorQueue = null;
 }
コード例 #32
0
 public ConcurrentSqsReceiver(IAmazonSQS amazonSQSClient, QueueByName queueByName, Func<Message, bool> onReceived,
     Action<Exception, Message> onError, int maxNumberOfMessages = 1, int concurrency = 1)
     : this(amazonSQSClient, new QueueConfiguration(amazonSQSClient, queueByName), onReceived, onError, maxNumberOfMessages, concurrency)
 {
 }
コード例 #33
0
 /// <summary>
 /// Implements the Dispose pattern
 /// </summary>
 /// <param name="disposing">Whether this object is being disposed via a call to Dispose
 /// or garbage collected.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             if (snsClient != null)
             {
                 snsClient.Dispose();
                 snsClient = null;
             }
             if (sqsClient != null)
             {
                 sqsClient.Dispose();
                 sqsClient = null;
             }
         }
         this.disposed = true;
     }
 }
コード例 #34
0
 public SequentialSQSReceiver(IAmazonSQS amazonSQSClient, QueueByName queueByName, Func<Message, bool> onRecieved,
     Action<Exception, Message> onError, int maxNumberOfMessages = DefaultNumberOfMessagesToReceiveAtATime) :
     this(amazonSQSClient, new QueueConfiguration(amazonSQSClient, queueByName), onRecieved, onError, maxNumberOfMessages)
 {
 }
コード例 #35
0
ファイル: SqsQueueBase.cs プロジェクト: denizkocak/JustSaying
 protected SqsQueueBase(RegionEndpoint region, IAmazonSQS client)
 {
     this.Region = region;
     Client = client;
 }
コード例 #36
0
 public SqsQueueByName(RegionEndpoint region, string queueName, IAmazonSQS client, int retryCountBeforeSendingToErrorQueue)
     : base(region, queueName, client)
 {
     _retryCountBeforeSendingToErrorQueue = retryCountBeforeSendingToErrorQueue;
     ErrorQueue = new ErrorQueue(region, queueName, client);
 }
コード例 #37
0
 protected SqsQueueBase(IAmazonSQS client)
 {
     Client = client;
 }
コード例 #38
0
        public void Dispose()
        {   // Do our best to drain all the buffers
            Drain(fullDrain: true, nakReceived: true);

            if (sqsClient == null)
            {
                return;
            }

            try
            {
                sqsClient.Dispose();
                sqsClient = null;
            }
            catch { }
        }
コード例 #39
0
 public SqsQueueByUrl(RegionEndpoint region, string queueUrl, IAmazonSQS client)
     : base(region, client)
 {
     Url = queueUrl;
 }
コード例 #40
0
 public QueueConfiguration(IAmazonSQS amazonSqsClient, QueueByName queueByName)
 {
     _amazonSQSClient = amazonSqsClient;
     _queueByName = queueByName;
 }
コード例 #41
0
 public DummySqsQueue(Uri uri, IAmazonSQS client, ILoggerFactory loggerFactory)
     : base(RegionEndpoint.EUWest1, client, loggerFactory)
 {
     Uri       = uri;
     QueueName = "DummySqsQueue";
 }
コード例 #42
0
 protected SqsQueueByNameBase(RegionEndpoint region, string queueName, IAmazonSQS client, ILoggerFactory loggerFactory)
     : base(region, client)
 {
     QueueName = queueName;
     _log      = loggerFactory.CreateLogger("JustSaying");
 }
コード例 #43
0
 protected SqsQueueByNameBase(RegionEndpoint region, string queueName, IAmazonSQS client)
     : base(region, client)
 {
     QueueName = queueName;
 }
コード例 #44
0
 public IEnumerable <ReceivedMessage> BuildMessages(IEnumerable <Message> responseMessages, IAmazonSQS sqsClient,
                                                    string requestQueueUrl)
 {
     if (responseMessages == null)
     {
         return(new List <ReceivedMessage>());
     }
     return(responseMessages.Select(message => new ReceivedMessage
     {
         Body = message.Body,
         MessageId = message.MessageId,
         Attributes = message.Attributes,
         MessageAttributes = message.MessageAttributes,
         RemoveFromQueueAsync = () => sqsClient.DeleteMessageAsync(requestQueueUrl, message.ReceiptHandle)
     }).ToList());
 }
コード例 #45
0
 protected SqsConsumer(IAmazonSQS sqsClient, string sqsUrl, bool deleteSuccessfulMessages = false)
 {
     this.sqsClient = sqsClient;
     this.deleteSuccessfulMessages = deleteSuccessfulMessages;
     SqsQueueUrl = sqsUrl;
 }
コード例 #46
0
ファイル: QueueAdmin.cs プロジェクト: brandonc/amazonsqs
 public QueueAdmin(string awsAccessKey, string awsSecretKey)
 {
     this.client = AWSClientFactory.CreateAmazonSQSClient(
         awsAccessKey, awsSecretKey
     );
 }
コード例 #47
0
 public QueueService()
 {
     _sqsService = new AmazonSQSClient();
 }
コード例 #48
0
        public void Dispose()
        {
            if (sqsClient == null)
                return;

            try
            {
                sqsClient.Dispose();
                sqsClient = null;
            }
            catch { }
        }
コード例 #49
0
 public GameRankQueueManager(IAmazonSQS sqs)
 {
     _sqs = sqs ?? throw new ArgumentNullException(nameof(sqs));
 }
コード例 #50
0
 //Get only one of these
 public QueueStuff(){
    SQS = AWSClientFactory.CreateAmazonSQSClient(RegionEndpoint.EUWest1);
 }
コード例 #51
0
        protected override void ConfigureWebHost(IWebHostBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                EnsureEnvVarConfigured("Localstack_SnsServiceUrl", "http://localhost:4566");

                services.RemoveAll(typeof(DbContextOptions <RepairsContext>));

                services.AddDbContext <RepairsContext>(options =>
                {
                    if (_connection != null)
                    {
                        options.UseNpgsql(_connection)
                        .UseSnakeCaseNamingConvention()
                        .UseLazyLoadingProxies();
                    }
                    else
                    {
                        options.UseInMemoryDatabase("integration")
                        .UseLazyLoadingProxies()
                        .UseSnakeCaseNamingConvention();
                        options.ConfigureWarnings(warningOptions =>
                        {
                            warningOptions.Ignore(InMemoryEventId.TransactionIgnoredWarning);
                        });
                    }
                });

                var serviceProvider = services.BuildServiceProvider();
                InitialiseDB(serviceProvider);

                services.RemoveAll <IApiGateway>();
                services.AddTransient <IApiGateway, MockApiGateway>();
                services.RemoveAll <SOAP>();
                services.RemoveAll <IAsyncNotificationClient>();
                services.AddTransient(sp => _notifyMock.Object);
                services.AddTransient(sp => _soapMock.Object);
                services.RemoveAll(typeof(ILogger <>));
                services.AddTransient(typeof(ILogger <>), typeof(MockLogger <>));
                services.AddSingleton(_log);

                // Configure integration/E2E tests via localstack
                services.AddFilteringConfig();


                services.RemoveAll <IAmazonSimpleNotificationService>();

                var localstackUrl = Environment.GetEnvironmentVariable("Localstack_SnsServiceUrl");
                services.AddSingleton <IAmazonSimpleNotificationService>(sp =>
                {
                    var clientConfig = new AmazonSimpleNotificationServiceConfig {
                        ServiceURL = localstackUrl
                    };
                    return(new AmazonSimpleNotificationServiceClient(clientConfig));
                });

                services.ConfigureSns();
                services.AddSnsGateway();
                SimpleNotificationService = serviceProvider.GetRequiredService <IAmazonSimpleNotificationService>();

                AmazonSQS = new AmazonSQSClient(new AmazonSQSConfig()
                {
                    ServiceURL = localstackUrl
                });
            })
            .UseEnvironment("IntegrationTests");
        }
コード例 #52
0
 protected SqsQueueByNameBase(RegionEndpoint region, string queueName, IAmazonSQS client)
     : base(region, client)
 {
     QueueName = queueName;
 }
コード例 #53
0
 public SqsQueueByName(RegionEndpoint region, string queueName, IAmazonSQS client, int retryCountBeforeSendingToErrorQueue)
     : base(region, queueName, client)
 {
     _retryCountBeforeSendingToErrorQueue = retryCountBeforeSendingToErrorQueue;
     ErrorQueue = new ErrorQueue(region, queueName, client);
 }
コード例 #54
0
 public SqsPublisher(RegionEndpoint region, string queueName, IAmazonSQS client, int retryCountBeforeSendingToErrorQueue, IMessageSerialisationRegister serialisationRegister)
     : base(region, queueName, client, retryCountBeforeSendingToErrorQueue)
 {
     _client = client;
     _serialisationRegister = serialisationRegister;
 }
コード例 #55
0
 public SqsQueueByUrl(RegionEndpoint region, string queueUrl, IAmazonSQS client)
     : base(region, client)
 {
     Url = queueUrl;
 }
コード例 #56
0
        internal DownloadFileCommand(ArchiveTransferManager manager, string vaultName, string archiveId, string filePath, DownloadOptions options)
        {
            this.manager = manager;
            this.vaultName = vaultName;
            this.archiveId = archiveId;
            this.filePath = filePath;
            this.options = options;

            var credentials = ((AmazonGlacierClient)this.manager.GlacierClient).GetCredentials();
            var glacierClient = this.manager.GlacierClient as AmazonGlacierClient;
            if (glacierClient == null)
                throw new InvalidOperationException("This can only be called using an AmazonGlacierClient");

            this.snsClient = new AmazonSimpleNotificationServiceClient(credentials, glacierClient.CloneConfig<AmazonSimpleNotificationServiceConfig>());
            this.sqsClient = new AmazonSQSClient(credentials, glacierClient.CloneConfig<AmazonSQSConfig>());

            if (this.options == null)
                this.options = new DownloadOptions();
        }
コード例 #57
0
 public ErrorQueue(string sourceQueueName, IAmazonSQS client)
     : base(sourceQueueName + "_error", client)
 {
     ErrorQueue = null;
 }
コード例 #58
0
 public SqsQueueByUrl(string queueUrl, IAmazonSQS client)
     : base(client)
 {
     Url = queueUrl;
 }
コード例 #59
0
 public SqsPublisher(IAmazonSQS sqsClient)
 {
     _sqsClient = sqsClient;
 }
コード例 #60
0
 public SqsQueueByNameBase(string queueName, IAmazonSQS client)
     : base(client)
 {
     QueueName = queueName;
     Exists();
 }