In one of my Akka applications (my first, and not one I'd hold up as a shining example of how to write such systems), I implement a low-water / high-water work generation strategy driven by a heartbeat. The low and high water marks are defined in terms of number of work actors active, each of which does one thing and is created by a manager. That manager keeps track of started and as-yet unompleted workers and can respond to requests from the work generator for the current activity count. The response to these inquiries provides the information as to whether work in progress has fallen below the low-water mark and new work should be generated.
It's kind of crude and in a new system I'm working on now the connections between work generation and work execution, as well as checkpoint logging, is done in a more continuous, less "batch-oriented" manner. This system is about to be deployed, so at the moment I can't say for certain how it will perform, but I'm pretty sure it will exhibit better behavior than the earlier system. It's also inherently more complicated that the earlier system in how it generates, performs and records the work it does.
[Going to put this also as a valid answer]
If the actor who needs the count is not the parent and/or cannot retrieve the
ActorRefs of the target actors, then the following might be an alternative.
Counting the number of actors of a certain type can be done by sending a "head count" message, holding an
ActorRef array, passing each actor. Then each target actor can add it's ActorRef to that list and forward the message. But this depends on the nature of the system and works only if you know beyond any doubt that you don't have any actors spawning up during the "head count".
- How to count actors of a certain type active at a certain time in an akka system?
- How to send objects to remote akka actors in an asymmetric system
- How to set Akka actors run only for specific time period?
- How do I declare a constructor for an 'object' class type in Scala? I.e., a one time operation for the singleton
- How to wait for Akka actor system to terminate?
- How print all actors in akka system?
- How are akka actors implemented on underlying threads?
- How to start Akka Actors since 2.0?
- How to mock child Actors for testing an Akka system?
- how to create remote actors dynamically and control them by using AKKA
- How to recover messages in Akka Actors now that Durable Mailboxes are removed?
- How send messages to akka system in neighbouring jvm?
- How to cast a variable to certain runtime type got from TypeCast in Scala
- how can I count akka current open connections
- how to get System time using play framework and scala?
- How do I unit test akka actors in Play Framework 2.2.0 Scala (spec2, Mockito)
- How to enforce non-generic type at compile time
- How to require at compile time that a type parameter be a trait (and not a class or other type value)?
- How can I pass my logback.xml into my akka application as a system property?
- How does the Scala type system know that cons + Nil is exhaustive?
- Akka Streams: How do I model capacity/rate limiting within a system of 2 related streams?
- How to hide Akka remote actors from lookup?
- How to subscribe actors into akka event bus automatically in Play2.4/Scala
- Show how much time the compiler spends on type inference
- How to map a function over the HList of functions from a certain type to some type?
- Create akka system where all actors have references to each other
- How to specify a shapeless singleton type ahead of time
- How to implement type-safe extensible type system in Scala?
- Akka 2.0 Remoting: How do I start/allocate remote actors at runtime
- Scala and Akka - Testing actors as a system with Akka Testkit
More Query from same tag
- Are there tools or techniques to search for compatible newer versions of package dependencies?
- How to remove duplicate values from list using scala?
- Simple form post receiving Unauthorized
- Does Scala provide an easy way to convert Infix expressions to postfix ones?
- Using LabelDef in scala macros (2.10)
- Glue Spark Scala Script to check if file exist in S3?
- How to deal with complex operation on Map in Scala
- JSON deserialization with fields that can have different types (using Jackson and Scala)
- ClassCastException when trying to insert with Squeryl
- n-way `span` on sequences
- "is not a member of package" error when importing package in Scala with SBT
- Why put a generic type next to a function?
- what's the difference between def and var/val for an anonymous function
- How to get the parameter of a type constructor in Scala?
- java.lang.RuntimeException: No main class detected - Docker
- Passing DEFAULTS args in function scala
- Scala: Imported scala object with implicits not working for providing Read or Write format (play json)
- Scala upper type bounds and parent classes
- Play Framework float in Template with comma
- Extend trait from another module
- Is it possible to call a generically-typed function by passing in a class specified in a map?
- Scala style guideline for underscore in identifiers
- Order of task execution in union() operation
- Data Frame Mapping in spark scala?
- Spark: RDD missing entries in each iteration
- Function calls with returned tuple without intermediate value
- Error on overriding method reads in trait Reads
- Scala: How to get an Enumeration "Value" from a literal
- Spark SQL join really lazy?
- Why does database initialization fail with "ERROR: improper qualified name (too many dotted names)"?