public void A_borken_Flow_must_cancel_upstream_and_call_onError_on_current_and_future_downstream_subscribers_if_an_internal_error_occurs() { var setup = new ChainSetup <string, string, NotUsed>(FaultyFlow <string, string, string>, Settings.WithInputBuffer(1, 1), (settings, factory) => ActorMaterializer.Create(factory, settings), (source, materializer) => ToFanoutPublisher(source, materializer, 16), this); Action <TestSubscriber.ManualProbe <string> > checkError = sprobe => { var error = sprobe.ExpectError(); error.Should().BeOfType <AbruptTerminationException>(); error.Message.Should().StartWith("Processor actor"); }; var downstream2 = this.CreateManualSubscriberProbe <string>(); setup.Publisher.Subscribe(downstream2); var downstream2Subscription = downstream2.ExpectSubscription(); setup.DownstreamSubscription.Request(5); downstream2Subscription.Request(5); setup.Upstream.ExpectRequest(setup.UpstreamSubscription, 1); setup.UpstreamSubscription.SendNext("a1"); setup.Downstream.ExpectNext("a1"); downstream2.ExpectNext("a1"); setup.Upstream.ExpectRequest(setup.UpstreamSubscription, 1); setup.UpstreamSubscription.SendNext("a2"); setup.Downstream.ExpectNext("a2"); downstream2.ExpectNext("a2"); var filters = new EventFilterBase[] { new ErrorFilter(typeof(NullReferenceException)), new ErrorFilter(typeof(IllegalStateException)), new ErrorFilter(typeof(PostRestartException)),// This is thrown because we attach the dummy failing actor to toplevel }; try { Sys.EventStream.Publish(new Mute(filters)); setup.Upstream.ExpectRequest(setup.UpstreamSubscription, 1); setup.UpstreamSubscription.SendNext("a3"); setup.UpstreamSubscription.ExpectCancellation(); // IllegalStateException terminated abruptly checkError(setup.Downstream); checkError(downstream2); var downstream3 = this.CreateManualSubscriberProbe <string>(); setup.Publisher.Subscribe(downstream3); downstream3.ExpectSubscription(); // IllegalStateException terminated abruptly checkError(downstream3); } finally { Sys.EventStream.Publish(new Unmute(filters)); } }
public void PersistentActor_with_a_failing_snapshot_loading_must_fail_recovery_and_stop_actor_when_no_snapshot_could_be_loaded() { var filters = new EventFilterBase[] { new ErrorFilter(typeof(Exception), new ContainsString("kanbudong")) }; Sys.EventStream.Subscribe(TestActor, typeof(Error)); Sys.EventStream.Publish(new Mute(filters)); try { var lPersistentActor = Sys.ActorOf(Props.Create(() => new LoadSnapshotTestPersistentActor(Name, TestActor))); ExpectMsg <Error>(msg => msg.Message.ToString().StartsWith("Persistence failure when replaying events for persistenceId")); Watch(lPersistentActor); ExpectTerminated(lPersistentActor); } finally { Sys.EventStream.Unsubscribe(TestActor, typeof(Error)); Sys.EventStream.Publish(new Unmute(filters)); } }
/// <summary> /// TBD /// </summary> /// <param name="filter">TBD</param> /// <param name="system">TBD</param> /// <returns>TBD</returns> protected IEventFilterApplier CreateApplier(EventFilterBase filter, ActorSystem system) { EventFilterBase[] allFilters; //This will contain _filters + filter if (_filters == null || _filters.Count == 0) { allFilters = new[] { filter }; } else { var existingFiltersCount = _filters.Count; allFilters = new EventFilterBase[existingFiltersCount + 1]; //Copy everything from _filters to allFilter and put filter at the end for (var i = 0; i < existingFiltersCount; i++) { allFilters[i] = _filters[i]; } allFilters[existingFiltersCount] = filter; } return(new InternalEventFilterApplier(_testkit, system, allFilters)); }