Beispiel #1
0
        public async Task A_QueueSink_should_skip_failing_messages_if_supervision_strategy_is_restart()
        {
            await Queue.DeleteIfExistsAsync();

            var queueSink = QueueSink.Create(Queue)
                            .WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.RestartingDecider));

            var t = this.SourceProbe <string>()
                    //.Select(x => new QueueMessage(x))
                    .ToMaterialized(queueSink, Keep.Both)
                    .Run(Materializer);

            var probe = t.Item1;
            var task  = t.Item2;

            probe.SendNext("1");
            await Task.Delay(500);

            await Queue.CreateAsync();

            probe.SendNext("2");
            probe.SendComplete();
            await task;

            (await Queue.ReceiveMessagesAsync()).Value[0].MessageText.Should().Be("2");
        }
Beispiel #2
0
        public async Task A_QueueSink_should_set_the_exception_of_the_task_when_an_error_occurs()
        {
            var(probe, task) = this.SourceProbe <string>()
                               //.Select(x => new QueueMessage(x))
                               .ToMaterialized(QueueSink.Create(Queue), Keep.Both)
                               .Run(Materializer);

            probe.SendError(new Exception("Boom"));
            task.Invoking(async x => await x).Should().Throw <Exception>().WithMessage("Boom");
        }
Beispiel #3
0
        public void A_QueueSink_should_set_the_exception_of_the_task_when_an_error_occurs()
        {
            var t = this.SourceProbe <string>()
                    .Select(x => new CloudQueueMessage(x))
                    .ToMaterialized(QueueSink.Create(Queue), Keep.Both)
                    .Run(Materializer);
            var probe = t.Item1;
            var task  = t.Item2;

            probe.SendError(new Exception("Boom"));
            task.Invoking(x => x.Wait(TimeSpan.FromSeconds(3))).ShouldThrow <Exception>().WithMessage("Boom");
        }
Beispiel #4
0
        public void A_QueueSink_should_retry_failing_messages_if_supervision_strategy_is_resume()
        {
            Queue.DeleteIfExists();
            var messages  = new[] { "1", "2" };
            var queueSink = QueueSink.Create(Queue)
                            .WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.ResumingDecider));

            var t = Source.From(messages)
                    .Select(x => new CloudQueueMessage(x))
                    .RunWith(queueSink, Materializer);

            Thread.Sleep(1000);
            Queue.Create();
            t.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
            Queue.GetMessages(2).Select(x => x.AsString).ShouldAllBeEquivalentTo(messages);
        }
Beispiel #5
0
        public async Task A_QueueSink_should_retry_failing_messages_if_supervision_strategy_is_resume()
        {
            await Queue.DeleteIfExistsAsync();

            var messages  = new[] { "1", "2" };
            var queueSink = QueueSink.Create(Queue)
                            .WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.ResumingDecider));

            var t = Source.From(messages)
                    //.Select(x => new QueueMessage(x))
                    .RunWith(queueSink, Materializer);

            await Task.Delay(1000);

            await Queue.CreateAsync();

            t.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
            (await Queue.ReceiveMessagesAsync(2)).Value.Select(x => x.MessageText).Should().BeEquivalentTo(messages);
        }
Beispiel #6
0
        public void A_QueueSink_should_skip_failing_messages_if_supervision_strategy_is_restart()
        {
            Queue.DeleteIfExists();
            var queueSink = QueueSink.Create(Queue)
                            .WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.RestartingDecider));

            var t = this.SourceProbe <string>()
                    .Select(x => new CloudQueueMessage(x))
                    .ToMaterialized(queueSink, Keep.Both)
                    .Run(Materializer);

            var probe = t.Item1;
            var task  = t.Item2;

            probe.SendNext("1");
            Thread.Sleep(500);
            Queue.Create();
            probe.SendNext("2");
            probe.SendComplete();
            task.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
            Queue.GetMessage().AsString.Should().Be("2");
        }