File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed
Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 1+ using Akka . Actor ;
2+ using Akka . Event ;
3+
4+ namespace BLUECATS . ToastNotifier . Actors
5+ {
6+ public class EventSubscribeActor : ReceiveActor , IWithUnboundedStash
7+ {
8+ public IStash Stash { get ; set ; }
9+
10+ public static Props Props ( IActorRef notificationActor )
11+ {
12+ return Akka . Actor . Props . Create ( ( ) => new EventSubscribeActor ( notificationActor ) ) ;
13+ }
14+
15+ public EventSubscribeActor ( IActorRef notificationActor )
16+ {
17+ Receive < Error > ( m => { notificationActor . Tell ( m . ToString ( ) ) ; } ) ;
18+ }
19+ }
20+ }
Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ public NotificationActor(Notifier notifier)
4444
4545 BecomeStacked ( Delaying ) ;
4646 } ) ;
47+
48+ Receive < string > ( m => notifier . ShowError ( m ) ) ;
4749 }
4850
4951 private void Delaying ( )
Original file line number Diff line number Diff line change @@ -55,8 +55,6 @@ protected override void OnStartup(StartupEventArgs e)
5555 var fileVersionInfo = FileVersionInfo . GetVersionInfo ( assembly . Location ) ;
5656 _version = fileVersionInfo . ProductVersion ;
5757
58-
59-
6058 var config = AkkaHelper . ReadConfigurationFromHoconFile ( Assembly . GetExecutingAssembly ( ) , "conf" )
6159 . WithFallback ( ConfigurationFactory . FromResource < ConsumerSettings < object , object > > ( "Akka.Streams.Kafka.reference.conf" ) ) ;
6260
@@ -68,7 +66,8 @@ protected override void OnStartup(StartupEventArgs e)
6866
6967 notificationActor = system . ActorOf ( NotificationActor . Props ( Notifier ) , nameof ( NotificationActor ) ) ;
7068 var parserActor = system . ActorOf ( ParserActor . Props ( notificationActor ) , nameof ( ParserActor ) ) ;
71-
69+ var eventSubscribeActor = system . ActorOf ( EventSubscribeActor . Props ( notificationActor ) , nameof ( EventSubscribeActor ) ) ;
70+ system . EventStream . Subscribe ( eventSubscribeActor , typeof ( Akka . Event . Error ) ) ;
7271
7372 var bootStrapServers = GetBootStrapServers ( config ) ;
7473
@@ -91,6 +90,7 @@ protected override void OnStartup(StartupEventArgs e)
9190 catch ( Exception ex )
9291 {
9392 MessageBox . Show ( ex . ToString ( ) ) ;
93+ Current . Shutdown ( ) ;
9494 }
9595
9696 base . OnStartup ( e ) ;
You can’t perform that action at this time.
0 commit comments