Example #1
0
        public void SqsAckFlow_grouped_stream_should_react_on_ChangeVisibility_commands()
        {
            client.ChangeMessageVisibilityBatchAsync(Arg.Any <ChangeMessageVisibilityBatchRequest>()).Returns(req =>
                                                                                                              Task.FromResult(new ChangeMessageVisibilityBatchResponse
            {
                Failed     = new List <BatchResultErrorEntry>(0),
                Successful = ((ChangeMessageVisibilityBatchRequest)req[0]).Entries
                             .Select(e => new ChangeMessageVisibilityBatchResultEntry
                {
                    Id = e.Id
                }).ToList()
            }));

            var publisher  = this.CreatePublisherProbe <MessageAction>();
            var subscriber = this.CreateSubscriberProbe <ISqsAckResultEntry>();

            Source.FromPublisher(publisher)
            .Via(SqsAckFlow.Grouped(client, TestQueueUrl))
            .To(Sink.FromSubscriber(subscriber))
            .Run(materializer);

            subscriber.Request(3);

            publisher.SendNext(MessageAction.ChangeVisibility(Message("a-1"), 10.Seconds()));
            publisher.SendNext(MessageAction.ChangeVisibility(Message("a-2"), 13.Seconds()));

            subscriber.ExpectNext <ISqsAckResultEntry>(ack => ack is SqsChangeMessageVisibilityResultEntry r &&
                                                       r.Action.Message.ReceiptHandle == "a-1" && r.Action.VisibilityTimeout == 10.Seconds());
            subscriber.ExpectNext <ISqsAckResultEntry>(ack => ack is SqsChangeMessageVisibilityResultEntry r &&
                                                       r.Action.Message.ReceiptHandle == "a-2" && r.Action.VisibilityTimeout == 13.Seconds());

            subscriber.Cancel();
        }
Example #2
0
        public void SqsAckFlow_default_stream_should_react_on_ChangeVisibility_commands()
        {
            client.ChangeMessageVisibilityAsync(Arg.Any <ChangeMessageVisibilityRequest>()).Returns(
                Task.FromResult(new ChangeMessageVisibilityResponse()));

            var publisher  = this.CreatePublisherProbe <MessageAction>();
            var subscriber = this.CreateSubscriberProbe <ISqsAckResult>();

            Source.FromPublisher(publisher)
            .Via(SqsAckFlow.Default(client, TestQueueUrl, SqsAckSettings.Default.WithMaxInFlight(1)))
            .To(Sink.FromSubscriber(subscriber))
            .Run(materializer);

            subscriber.Request(3);

            publisher.SendNext(MessageAction.ChangeVisibility(Message("a-1"), 10.Seconds()));
            publisher.SendNext(MessageAction.ChangeVisibility(Message("a-2"), 13.Seconds()));

            subscriber.ExpectNext <ISqsAckResult>(ack => ack is SqsChangeMessageVisibilityResult r &&
                                                  r.Action.Message.ReceiptHandle == "a-1" && r.Action.VisibilityTimeout == 10.Seconds());
            subscriber.ExpectNext <ISqsAckResult>(ack => ack is SqsChangeMessageVisibilityResult r &&
                                                  r.Action.Message.ReceiptHandle == "a-2" && r.Action.VisibilityTimeout == 13.Seconds());

            subscriber.Cancel();
        }
Example #3
0
        public void SqsAckFlow_grouped_stream_should_react_on_Delete_commands()
        {
            client.DeleteMessageBatchAsync(Arg.Any <DeleteMessageBatchRequest>()).Returns(req =>
                                                                                          Task.FromResult(new DeleteMessageBatchResponse
            {
                Failed     = new List <BatchResultErrorEntry>(0),
                Successful = ((DeleteMessageBatchRequest)req[0]).Entries
                             .Select(e => new DeleteMessageBatchResultEntry
                {
                    Id = e.Id
                }).ToList()
            }));

            var publisher  = this.CreatePublisherProbe <MessageAction>();
            var subscriber = this.CreateSubscriberProbe <ISqsAckResultEntry>();

            Source.FromPublisher(publisher)
            .Via(SqsAckFlow.Grouped(client, TestQueueUrl, SqsAckGroupedSettings.Default))
            .To(Sink.FromSubscriber(subscriber))
            .Run(materializer);

            subscriber.Request(3);

            publisher.SendNext(MessageAction.Delete(Message("a-1")));
            publisher.SendNext(MessageAction.Delete(Message("a-2")));

            subscriber.ExpectNext <ISqsAckResultEntry>(ack => ack is SqsDeleteResultEntry r && r.Action.Message.ReceiptHandle == "a-1");
            subscriber.ExpectNext <ISqsAckResultEntry>(ack => ack is SqsDeleteResultEntry r && r.Action.Message.ReceiptHandle == "a-2");

            subscriber.Cancel();
        }
Example #4
0
        public void SqsAckFlow_default_stream_should_react_on_Ignore_commands()
        {
            var publisher  = this.CreatePublisherProbe <MessageAction>();
            var subscriber = this.CreateSubscriberProbe <ISqsAckResult>();

            Source.FromPublisher(publisher)
            .Via(SqsAckFlow.Default(client, TestQueueUrl, SqsAckSettings.Default.WithMaxInFlight(1)))
            .To(Sink.FromSubscriber(subscriber))
            .Run(materializer);

            subscriber.Request(3);

            publisher.SendNext(MessageAction.Ignore(Message("a-1")));
            publisher.SendNext(MessageAction.Ignore(Message("a-2")));

            subscriber.ExpectNext <ISqsAckResult>(ack => ack is SqsIgnoreResult r && r.Action.Message.ReceiptHandle == "a-1");
            subscriber.ExpectNext <ISqsAckResult>(ack => ack is SqsIgnoreResult r && r.Action.Message.ReceiptHandle == "a-2");

            subscriber.Cancel();
        }