Exemplo n.º 1
0
 public void ShouldBeAbleToFilterDeadLetters()
 {
     EventFilter.DeadLetter().ExpectOne(() =>
     {
         _deadActor.Tell("whatever");
     });
 }
Exemplo n.º 2
0
        public void AkkaProtocolTransport_must_guarantee_at_most_once_delivery_and_message_ordering_despite_packet_loss()
        {
            //todo mute both systems for deadletters for any type of message
            EventFilter.DeadLetter().Mute();
            CreateEventFilter(systemB).DeadLetter().Mute();
            var mc =
                RARP.For(Sys)
                .Provider.Transport.ManagementCommand(new FailureInjectorTransportAdapter.One(AddressB,
                                                                                              new FailureInjectorTransportAdapter.Drop(0.1, 0.1)));

            AwaitCondition(() => mc.IsCompleted && mc.Result, TimeSpan.FromSeconds(3));

            IActorRef here = null;

            AwaitCondition(() =>
            {
                here = Here;
                return(here != null && !here.Equals(ActorRefs.Nobody));
            }, TimeSpan.FromSeconds(3));

            var tester = Sys.ActorOf(Props.Create(() => new SequenceVerifier(here, TestActor)));

            tester.Tell("start");

            ExpectMsg <(int, int)>(TimeSpan.FromSeconds(60));
        }
Exemplo n.º 3
0
        public void ShouldSendToDeadLettersForUndeliveredMessage()
        {
            IActorRef actor = ActorOf(Props.Create(() => new UserActor(ActorOf(BlackHoleActor.Props))));

            EventFilter.DeadLetter <PlayMovieMessage>(
                message => message.TitleName == "Boolean Lies")
            .ExpectOne(() => actor.Tell(new PlayMovieMessage("Boolean Lies")));
        }
Exemplo n.º 4
0
        public async Task Ask_should_put_invalid_answer_into_deadletter()
        {
            var actor = Sys.ActorOf <SomeActor>();

            await EventFilter.DeadLetter <object>().ExpectOne(async() =>
            {
                await Assert.ThrowsAsync <ArgumentException>(async() => await actor.Ask <string>("invalid", TimeSpan.FromSeconds(1)));
            });
        }
Exemplo n.º 5
0
        public void An_ActorRef_should_never_have_a_null_Sender_Bug_1212()
        {
            var actor = ActorOfAsTestActorRef <NonPublicActor>(Props.Create <NonPublicActor>(SupervisorStrategy.StoppingStrategy));

            // actors with a null sender should always write to deadletters
            EventFilter.DeadLetter <object>().ExpectOne(() => actor.Tell(new object(), null));

            // will throw an exception if there's a bug
            ExpectNoMsg();
        }
Exemplo n.º 6
0
        public async Task Ask_should_not_put_canceled_answer_into_deadletter()
        {
            var actor = Sys.ActorOf <SomeActor>();

            await EventFilter.DeadLetter <object>().ExpectAsync(0, async() =>
            {
                using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(1)))
                    await Assert.ThrowsAsync <TaskCanceledException>(async() => await actor.Ask <string>("delay", Timeout.InfiniteTimeSpan, cts.Token));
            });
        }
Exemplo n.º 7
0
        public async Task Ask_should_put_too_many_answers_into_deadletter()
        {
            var actor = Sys.ActorOf <SomeActor>();

            await EventFilter.DeadLetter <object>().ExpectAsync(2, async() =>
            {
                var result = await actor.Ask <string>("many", TimeSpan.FromSeconds(1));
                result.ShouldBe("answer1");
            });
        }
Exemplo n.º 8
0
        public void DefaultPipeline_should_unstash_all_terminated_actors_stashed_messages_on_stop()
        {
            // we'll send 3 int messages to stash by the actor and then stop it,
            // all stashed messages should then be unstashed back and sent to dead letters
            EventFilter.DeadLetter <int>().Expect(3, () =>
            {
                var actor = ActorOf <StashingActor>();
                // send some messages to stash
                actor.Tell(1);
                actor.Tell(2);
                actor.Tell(3);

                // stop actor
                actor.Tell(PoisonPill.Instance);
            });
        }
Exemplo n.º 9
0
        public void An_actor_must_unstash_all_messages_on_PostStop()
        {
            var stasher = ActorOf <StashEverythingActor>("stasher");

            Watch(stasher);
            //This message will be stashed by stasher
            stasher.Tell("message");

            //When stasher is stopped it should unstash message during poststop to mailbox
            //the mailbox will be emptied and the messages will be sent to deadletters
            EventFilter.DeadLetter <string>(s => s == "message", source: stasher.Path.ToString()).ExpectOne(() =>
            {
                Sys.Stop(stasher);
                ExpectTerminated(stasher);
            });
        }
Exemplo n.º 10
0
 public void MuteDeadLetters(ActorSystem system = null, params Type[] messageClasses)
 {
     if (system == null)
     {
         system = Sys;
     }
     if (!system.Log.IsDebugEnabled)
     {
         if (messageClasses.Any())
         {
             foreach (var @class in messageClasses)
             {
                 EventFilter.DeadLetter(@class).Mute();
             }
         }
         else
         {
             EventFilter.DeadLetter(typeof(object)).Mute();
         }
     }
 }