Example #1
0
 public void SupervisedTest()
 {
     TestLauncherActor.Test(() =>
     {
         var supervisor = new SupervisorActor();
         ISupervisedActor supervised = new SupervisedActor();
         supervisor.SendMessage(SupervisorAction.Register, supervised);
         supervisor.SendMessage(SupervisorAction.Kill, supervised);
         supervisor.SendMessage(SupervisorAction.Respawn, supervised);
     });
 }
 public void SupervisedTest()
 {
     fLauncher.SendAction(() =>
     {
         var supervisor = new SupervisorActor();
         ISupervisedActor supervised = new SupervisedActor();
         supervisor.SendMessage(SupervisorAction.Register, supervised);
         supervisor.SendMessage(SupervisorAction.Kill, supervised);
         supervisor.SendMessage(SupervisorAction.Respawn, supervised);
         fLauncher.Finish();
     });
     fLauncher.Wait();
 }
Example #3
0
        private static async Task Main(string[] args)
        {
            var baseUri    = new Uri(args[0]);
            var outputSize = args.Length > 1
                ? int.Parse(args[1])
                : DefaultOutputSize;


            using var system = ActorSystem.Create("getlink-system");
            var supervisor = system.ActorOf(
                SupervisorActor.CreateProps(),
                "supervisor");


            supervisor.Tell(new GetSiteLinksRequest(baseUri, outputSize));


            Console.WriteLine("Press any key to exit application");
            Console.WriteLine();
            Console.Read();

            await CoordinatedShutdown.Get(system)
            .Run(CoordinatedShutdown.ClrExitReason.Instance);
        }
Example #4
0
        internal bool Start()
        {
            var logger = new LoggerConfiguration()
                         .WriteTo.ColoredConsole()
                         .MinimumLevel.Information()
                         .CreateLogger();

            Serilog.Log.Logger = logger;

            ActorSystem = ActorSystem.Create("BankSystem", @"akka
{
    loglevel=INFO,
    loggers=[""Akka.Logger.Serilog.SerilogLogger, Akka.Logger.Serilog""]

    remote {
        helios.tcp {
            port = 8081
            hostname = localhost
        }
    }

    cluster {
        seed-nodes = [""akka.tcp://BankSystem@localhost:8081""]
        auto-down-unreachable-after = 5s
        sharding {
            least-shard-allocation-strategy.rebalance-threshold = 3
        }
    }

    actor {
        provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
        serializers {
                wire = ""Akka.Serialization.WireSerializer, Akka.Serialization.Wire""
        }
        serialization-bindings {
                ""System.Object"" = wire
        }
        persistence {
            journal {
                plugin = ""akka.persistence.journal.inmem""
                inmem {
                    class=""Akka.Persistence.Journal.MemoryJournal, Akka.Persistence""
                    plugin-dispatcher = ""akka.actor.default-dispatcher""
                }
            }
            snapshot-store {
                plugin = ""akka.persistence.snapshot - store.local""
                local {
                    class = ""Akka.Persistence.Snapshot.LocalSnapshotStore, Akka.Persistence""
                    plugin-dispatcher = ""akka.persistence.dispatchers.default-plugin-dispatcher""
                    stream-dispatcher = ""akka.persistence.dispatchers.default-stream-dispatcher""
                    dir = ""snapshots""
                }
            }
        }
    }
}");

            var sharding = ClusterSharding.Get(ActorSystem);
            var settings = ClusterShardingSettings.Create(ActorSystem);

            sharding.Start(
                typeName: "AccountsBoundedContextActor",
                entityProps: Props.Create <AccountsBoundedContextActor>(),
                settings: settings,
                idExtractor: x => Tuple.Create(x.ToString(), x), //FAKE
                shardResolver: x => x.ToString());               //FAKE

            Domain = ActorSystem.ActorOf(DomainActor.Props(), "domains");

            Application = ActorSystem.ActorOf(SupervisorActor.Props(), "Application");
            ActorSystem.ActorOf(SupervisorActor.Props(), "Input");
            ActorSystem.ActorOf(SupervisorActor.Props(), "Output");
            ActorSystem.ActorOf(SupervisorActor.Props(), "Repositories");

            System.Console.WriteLine($"Domain @ {Domain.Path}");

            Thread.Sleep(2000);

            // Simulates user interactions
            {
                var command = new CreateAccountCommand("AC001", 100);
                Application.Tell(command);
            }


            System.Threading.Thread.Sleep(1000);

            {
                var command = new TransferBetweenAccountsCommand("AC001", "AC002", 50);
                Application.Tell(command);
            }

            System.Threading.Thread.Sleep(4000);

            {
                var command = new CreateAccountCommand("AC002", 100);
                Application.Tell(command);
            }


            return(true);
        }