public Task StartActorSystem(StockHubHelper helper)
        {
            Console.WriteLine("STARTING AKKA.NET");

            var conf = ConfigurationFactory.ParseString(File.ReadAllText("app.conf"))
                       .BoostrapApplication(new AppBootstrapConfig(false, false));

            var actorSystem         = Sys = ActorSystem.Create("AkkaCqrsWeb", conf);
            var stockPublisherActor =
                actorSystem.ActorOf(Props.Create(() => new StockPublisherActor(helper)), "stockPublisher");

            var initialContactAddress = Environment.GetEnvironmentVariable("CLUSTER_SEEDS")?.Trim().Split(",")
                                        .Select(x => Address.Parse(x)).ToList();

            if (initialContactAddress == null)
            {
                actorSystem.Log.Error("No initial cluster contacts found. Please be sure that the CLUSTER_SEEDS environment variable is populated with at least one address.");
                return(Task.FromException(new ConfigurationException(
                                              "No initial cluster contacts found. Please be sure that the CLUSTER_SEEDS environment variable is populated with at least one address.")));
            }

            var configurator = actorSystem.ActorOf(
                Props.Create(() => new StockEventConfiguratorActor(stockPublisherActor, initialContactAddress)),
                "configurator");

            return(Task.CompletedTask);
        }
        public StockPublisherActor(StockHubHelper hub)
        {
            _hub = hub;

            ReceiveAsync <IPriceUpdate>(async p =>
            {
                try
                {
                    _log.Info("Received event {0}", p);
                    await hub.WritePriceChanged(p);
                }
                catch (Exception ex)
                {
                    _log.Error(ex, "Error while writing price update [{0}] to StockHub", p);
                }
            });

            ReceiveAsync <IVolumeUpdate>(async p =>
            {
                try
                {
                    _log.Info("Received event {0}", p);
                    await hub.WriteVolumeChanged(p);
                }
                catch (Exception ex)
                {
                    _log.Error(ex, "Error while writing volume update [{0}] to StockHub", p);
                }
            });
        }