How to inject parameters to Actors using Akka.Hosting? i.e. public ExampleActor(Service1 service){ _service = service; .... }
Service1 is a Service added to IServiceCollection during startup.
How to inject parameters to Actors using Akka.Hosting? i.e. public ExampleActor(Service1 service){ _service = service; .... }
Service1 is a Service added to IServiceCollection during startup.
You can use Akka.DependencyInjection with Akka.Hosting via the following syntax:
The
WithActorsline has an overload which exposes theDependencyResolver- that uses theIServiceProviderunder the hood and you can useDependencyResolver.Props<TActor>(non-DI'd arguments...)to instantiate an actor that resolves dependencies through its constructor.