Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 21 15:57
    Aaronontheweb closed #3877
  • Oct 21 15:57
    Aaronontheweb commented #3877
  • Oct 21 15:56

    Aaronontheweb on dev

    Persistence TestKit documentati… (compare)

  • Oct 21 15:56
    Aaronontheweb closed #3889
  • Oct 21 07:27
    dependabot-preview[bot] labeled #3999
  • Oct 21 07:27

    dependabot-preview[bot] on nuget

    Bump FluentAssertions from 4.14… (compare)

  • Oct 21 07:27
    dependabot-preview[bot] opened #3999
  • Oct 20 17:25
    valdisz synchronize #3889
  • Oct 20 17:17
    valdisz synchronize #3889
  • Oct 20 15:44
    valdisz synchronize #3889
  • Oct 20 09:22
    ismaelhamed commented #3863
  • Oct 19 23:39
    valdisz synchronize #3889
  • Oct 19 23:08
    edvinasz commented #2947
  • Oct 19 13:36
    Aaronontheweb commented #3973
  • Oct 19 13:34
    dependabot-preview[bot] synchronize #3995
  • Oct 19 13:34

    dependabot-preview[bot] on nuget

    Bump BenchmarkDotNet from 0.10.… (compare)

  • Oct 19 13:34
    dependabot-preview[bot] edited #3995
  • Oct 19 13:34
    dependabot-preview[bot] synchronize #3993
  • Oct 19 13:34

    dependabot-preview[bot] on nuget

    Bump Google.Protobuf from 3.9.1… (compare)

  • Oct 19 13:34
    dependabot-preview[bot] synchronize #3991
Nikita Tsukanov
@kekekeks
interface IDisposableActor<T> : IDisposable
{
    ActorRef Actor{get;}
}

class DisposableActor<T> : IDisposableActor<T>
{
    public ActorRef Actor {get; private set;}
    public DisposableActor()
    {
          Actor = ActorSystem.ActorOf<T>();
    }
    public void Dispose()
    {
         Actor.Tell(oisonPill.Instance, ActorRef.NoSender);
    }
}
Roger Johansson
@rogeralsing
Im not sure i follow, its not the actors that are injected, its dependencies into actors. So the actor ref would never be wrapped in anything in the di
Nikita Tsukanov
@kekekeks
I think that @Danthar tries to inject ActorRef in ASP.NET controller
And have it's lifetime managed by DI-container
Roger Johansson
@rogeralsing
Oh, that is not supported, you inject into actors, not actors into other stuff
Nikita Tsukanov
@kekekeks
It shouldn't be ever supported by Akka itself
Natan Vivo
@nvivo
@kekekeks actors don't need to be disposable
the actor system already knows exactly when they stop
Nikita Tsukanov
@kekekeks

actors don't need to be disposable

If you want DI container to manage something's lifetime on per-request basis you need it to be IDisposable

So if you need an actor per request, you wrap it in something that creates an actor for you and then kills it when request is complete
Natan Vivo
@nvivo
yes, but you don't need to do it with idisposable
you can just ask the actor to stop after your're done
it's already part of the actor system
Nikita Tsukanov
@kekekeks
It's not the part of ASP.NET
Roger Johansson
@rogeralsing
Actor lifecycle should never be handled by anything else than akka itself. Actors can restart and thus need its own pipeline into the DI container to resolve its own dependencies
Nikita Tsukanov
@kekekeks
ASP.NET won't tell the actor that it's no longer needed
ASP.NET won't tell the actor that request is completed
So if one wants to have an actor per-request, he has to wrap an ActorRef into something that provides that glue
This shouldn't be used inside actor code however
Only by external consumers
Natan Vivo
@nvivo
You can have an actor per request and never have to let asp.net know about that
Nikita Tsukanov
@kekekeks
Generally a bad idea in terms of ASP.NET
Since in this case you have to manually manage actor's lifetime
instead of letting DI-container to do its work
Natan Vivo
@nvivo
@kekekeks you need to consider actor lifetime is a feature of akka. it's not a burden.
Nikita Tsukanov
@kekekeks
If external code claims some resource (actor in our case), it should free it at some point
Otherwise you'll get a lot of actors not being using and just eating the memory
Or you'll have to use RecieveTimeout to kill the actors
which isn't a good solution either, since it may kill the actor before request completes
Roger Johansson
@rogeralsing
That is done using either .stop or sending poisonpill, not by calling dispose
See the actor system as its own container, bad idea to try to have two competing containers decide when to kill things
The same things that is
Roger Johansson
@rogeralsing
You can create a factory that creates the actor for you, and if the factory is disposed, you send poisonpill to kill the actor. That way, the ActorSystem is in charge all the time, while you still can inject the factory and get the actorref
Natan Vivo
@nvivo
@rogeralsing Is Pigeon.conf really always loaded by the actor system, or is it just a reference?
Roger Johansson
@rogeralsing
Then DI the factory whereever you need it
Arjen Smits
@Danthar
and back. catching up on reading
Roger Johansson
@rogeralsing
Always loaded , its the fallback for properties that the user config didnt supply
Natan Vivo
@nvivo
thanks
Roger Johansson
@rogeralsing
There are probably some old JVM gunk in there still
Natan Vivo
@nvivo
@rogeralsing about the dispatchers, do you have any other common use case for them, so I can mention in the documentation?
Roger Johansson
@rogeralsing
Yes, we have one dispatcher that captures current synchronizationcontext , so you can run actors in gui threads and update controls and such w/o threading issues
Eg if you want to async fill a grid or something
Natan Vivo
@nvivo
hmm. ok!
that's important
Roger Johansson
@rogeralsing
(Those actors should ofc not do heavy work, just update gui in a reactive way)
Maybe a reactive gui app for stock prices are a good example
There is also a pinned thread dispatcher, if you want to dedicate an entire thread to a specific actor
And the forkjoindispatcher, that has its own dedicated threadpool, to avoid noisy neigbours. Eg if some actors are more important than others, it can be isolated from the default shared threadpool
Natan Vivo
@nvivo
Thanks! that helps a lot, gave me already some direction
Arjen Smits
@Danthar
@rogeralsing You basically confirmed what I already expected. Akka uses the DI container to create an instance of your Actor, and after that, Akka is responsible for the lifecycle of the Actor. And not the DI container.