protected override ActorSystem CreateSystem(AkkaConfiguration conf) { Nodes = ActorSystemFactory.CreateCluster(AkkaConfig).NonSeedNodes; var actorSystem = Nodes.Last(); _transport = new DistributedPubSubTransport(actorSystem); return(actorSystem); }
//TODO: refactor to good config via IContainerConfiguration public static void Init(IUnityContainer container, ActorSystem actorSystem, TransportMode transportMode, IQuartzConfig config = null) { container.Register(new QuartzSchedulerConfiguration(config ?? new PersistedQuartzConfig())); container.RegisterInstance <IRetrySettings>(new InMemoryRetrySettings(5, TimeSpan.FromMinutes(10), new DefaultExceptionPolicy())); //TODO: replace with config IActorTransport transport; switch (transportMode) { case TransportMode.Standalone: transport = new LocalAkkaEventBusTransport(actorSystem); break; case TransportMode.Cluster: transport = new DistributedPubSubTransport(actorSystem); break; default: throw new ArgumentException(nameof(transportMode)); } container.RegisterInstance <IPublisher>(transport); container.RegisterInstance <IActorSubscriber>(transport); container.RegisterInstance <IActorTransport>(transport); container.RegisterType <IHandlerActorTypeFactory, DefaultHandlerActorTypeFactory>(); container.RegisterType <IAggregateActorLocator, DefaultAggregateActorLocator>(); container.RegisterType <IPersistentChildsRecycleConfiguration, DefaultPersistentChildsRecycleConfiguration>(); container.RegisterInstance <IAppInsightsConfiguration>(AppInsightsConfigSection.Default ?? new DefaultAppInsightsConfiguration()); container.RegisterInstance <IPerformanceCountersConfiguration>(PerformanceCountersConfigSection.Default ?? new DefaultPerfCountersConfiguration()); container.RegisterInstance(actorSystem); var executor = new AkkaCommandExecutor(actorSystem, transport); container.RegisterType <ICommandExecutor, AkkaCommandExecutor>(); var messageWaiterFactory = new MessageWaiterFactory(executor, actorSystem, TimeSpan.FromSeconds(15), transport); container.RegisterInstance <IMessageWaiterFactory>(messageWaiterFactory); container.RegisterInstance <ICommandWaiterFactory>(messageWaiterFactory); }