Getting an Overview of Actors in an Akka System
Join the DZone community and get the full member experience.
Join For Freei've been playing around with akka-http and akka-streams lately and was wondering which kinds of actors were created when i create flow graphs and process http requests. i ran into the typesafe console, but that is already end of live ( https://groups.google.com/forum/#!forum/typesafe-console ) and doesn't support the newer versions of akka.
so after some looking around i ran into a post on stackoverflow providing an alternative approach ( http://stackoverflow.com/questions/25860939/how-print-all-actors-in-akka... ):
this posts lists some pseudo code, which pointed me in pretty much the right direction. i currently use the following actor to print out all the actors in the system:
class idactor extends actor with actorlogging { def receive = { case "start" => log.info("current actors in system:") self ! actorpath.fromstring("akka://streams/user/") case path: actorpath => context.actorselection(path / "*") ! identify(()) case actoridentity(_, some(ref)) => log.info(ref.tostring()) self ! ref.path } }
to start this all we have to do is get the actor and message "start":
val idactor = system.actorof(props[idactor],"idactor"); idactor ! "start"
the result is very interesting. for instance in a http-akka system with a couple of flows running i get the following overview of actors:
current actors in system: actor[akka://streams/user/$a/flow-1-2-1-foreach-stagefactory#-1147809628] actor[akka://streams/user/$a/flow-1-2-1-foreach-stagefactory#-1147809628] actor[akka://streams/user/$a/flow-1-2-1-foreach-stagefactory#-1147809628] actor[akka://streams/user/$a/flow-1-2-1-foreach-stagefactory#-1147809628] actor[akka://streams/user/$a/flow-1-2-1-foreach-stagefactory#-1147809628] actor[akka://streams/user/$a#-992619289] actor[akka://streams/user/idactor#830993582] actor[akka://streams/user/$a/flow-1-1-map#310662784] ... actor[akka://streams/user/$a/flow-751-1-prefixandtail#801612770] actor[akka://streams/user/$a/flow-752-1-prefixandtail#-1939947471] actor[akka://streams/user/$a/flow-753-1-prefixandtail#102076528] actor[akka://streams/user/$a/flow-754-1-prefixandtail#-1858318406] actor[akka://streams/user/$a/flow-755-1-prefixandtail#595550267] actor[akka://streams/user/$a/flow-756-1-prefixandtail#-1675014490] actor[akka://streams/user/$a/flow-76-1-map#-1734873421] actor[akka://streams/user/$a/flow-93-1-map#174954170] actor[akka://streams/user/$a/flow-726-1-mapasync#2041440238] actor[akka://streams/user/$a/flow-725-1-mapasync#-674218071] actor[akka://streams/user/$a/flow-745-1-mapasync#-800760294]
cool right. not that you can do much with it, but it at least gives you a good overview of what is happening internally.
Published at DZone with permission of Jos Dirksen, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Best Practices for Securing Infrastructure as Code (Iac) In the DevOps SDLC
-
IntelliJ IDEA Switches to JetBrains YouTrack
-
A Data-Driven Approach to Application Modernization
-
How to Load Cypress Chrome Extension
Comments