Beispiel #1
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();
        }
Beispiel #2
0
        public void SqsAckFlow_default_stream_should_react_on_Delete_commands()
        {
            client.DeleteMessageAsync(Arg.Any <DeleteMessageRequest>()).Returns(
                Task.FromResult(new DeleteMessageResponse()));

            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.Delete(Message("a-1")));
            publisher.SendNext(MessageAction.Delete(Message("a-2")));

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

            subscriber.Cancel();
        }