DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Getting an Overview of Actors in an Akka System

Getting an Overview of Actors in an Akka System

Jos Dirksen user avatar by
Jos Dirksen
·
Feb. 04, 15 · Java Zone · Interview
Like (2)
Save
Tweet
3.57K Views

Join the DZone community and get the full member experience.

Join For Free

i'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... ):

listactors.png

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.

Akka (toolkit)

Published at DZone with permission of Jos Dirksen, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How to Determine if Microservices Architecture Is Right for Your Business
  • Java: Why Core-to-Core Latency Matters
  • ETL, ELT, and Reverse ETL
  • Modernizing Testing With Data Pipelines

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo