private PulsarSystem(ActorSystem actorSystem, PulsarClientConfigBuilder confBuilder) { _conf = confBuilder.ClientConfigurationData; var conf = _conf; _actorSystem = actorSystem; _conf = conf; _cnxPool = _actorSystem.ActorOf(ConnectionPool.Prop(conf), "ConnectionPool"); _generator = _actorSystem.ActorOf(IdGeneratorActor.Prop(), "IdGenerator"); _lookup = _actorSystem.ActorOf(BinaryProtoLookupService.Prop(_cnxPool, _generator, conf.ServiceUrl, conf.ListenerName, conf.UseTls, conf.MaxLookupRequest, conf.OperationTimeout), "BinaryProtoLookupService"); if (conf.EnableTransaction) { _tcClient = _actorSystem.ActorOf(TransactionCoordinatorClient.Prop(_lookup, _cnxPool, _generator, conf)); var cos = _tcClient.Ask <AskResponse>("Start").GetAwaiter().GetResult(); if (cos.Failed) { throw cos.Exception; } if ((int)cos.Data <= 0) { throw new Exception($"Tranaction Coordinator has '{cos}' transaction handler"); } } _client = _actorSystem.ActorOf(Props.Create <PulsarClientActor>(conf, _cnxPool, _tcClient, _lookup, _generator), "PulsarClient"); _lookup.Tell(new SetClient(_client)); }
private PulsarSystem(PulsarClientConfigBuilder confBuilder, Action logSetup, Config confg) { _conf = confBuilder.ClientConfigurationData; var conf = _conf; var logging = logSetup ?? _logSetup; logging(); _conf = conf; var config = confg ?? ConfigurationFactory.ParseString(@" akka { loglevel = DEBUG log-config-on-start = on loggers=[""Akka.Logger.NLog.NLogLogger, Akka.Logger.NLog""] actor { debug { receive = on autoreceive = on lifecycle = on event-stream = on unhandled = on } } coordinated-shutdown { exit-clr = on } }" ); _actorSystem = ActorSystem.Create("Pulsar", config); _cnxPool = _actorSystem.ActorOf(ConnectionPool.Prop(conf), "ConnectionPool"); _generator = _actorSystem.ActorOf(IdGeneratorActor.Prop(), "IdGenerator"); _lookup = _actorSystem.ActorOf(BinaryProtoLookupService.Prop(_cnxPool, _generator, conf.ServiceUrl, conf.ListenerName, conf.UseTls, conf.MaxLookupRequest, conf.OperationTimeout), "BinaryProtoLookupService"); if (conf.EnableTransaction) { _tcClient = _actorSystem.ActorOf(TransactionCoordinatorClient.Prop(_lookup, _cnxPool, _generator, conf)); var cos = _tcClient.Ask <AskResponse>("Start").GetAwaiter().GetResult(); if (cos.Failed) { throw cos.Exception; } if ((int)cos.Data <= 0) { throw new Exception($"Tranaction Coordinator has '{cos}' transaction handler"); } } _client = _actorSystem.ActorOf(Props.Create(() => new PulsarClientActor(conf, _cnxPool, _tcClient, _lookup, _generator)), "PulsarClient"); _lookup.Tell(new SetClient(_client)); }