Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7038271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:38:56+00:00 2026-05-28T01:38:56+00:00

This question is probably relatively basic to one familiar with akka Futures, so please

  • 0

This question is probably relatively basic to one familiar with akka Futures, so please bear with me.

Assuming I have a hierarchy of akka actors per the following structure:

BigBoss                 (one)
|___ExecutiveActor      (one)
    |___ManagerActor    (many)
        |___WorkerActor (many)

And assuming that each non-BigBoss has internal state in a Status wrapper.

If the BigBoss were to want a List<Status> from all descendants, I can see this being the method:

// inside BigBoss getAllStatuses
Future<Object> futureStatuses = executive.ask("status", 5000);
List<Status> = (List<Status>)Await.(futureStatuses, timeout);

And after the initial message is propagated to all the way down to Worker, I can see Worker replying to Manager with:

getSender().tell(myStatus);

Manager would have a lot of these coming back and want to put them in a list for the Executive as a list of Futures – the above reply being in response to:

// inside Manager getAllStatuses
List<Future<Object>> statuses =...
for(Worker w : workers) {
   Future<Object> status = w.ask("status", 5000);
   statuses.add(status);
}

Future<List<Object>> futureStatuses = sequence(statuses, ...);
getSender().tell(futureStatuses);

The above sequence first converts the Futures into a Future<List<Object>> (which really has statuses in it)

So this is where it starts to get a bit hairy to me.

ExecutiveActor had done this:

for(Manager m : managers) {
   Future<Object> status = m.ask("status", 5000);
   // the above Future would be a Future<Future<List<Object>>
}

So, finally – my questions –

  1. How do I reduce the above Future<Future<List<Object>> to a Future<List<Object>> without blocking until BigBoss finally calls Await?

  2. Is there a way to retain the Status type throughout this rather than using Object? I know an UntypedActor cannot send a explicit typed reply, but perhaps there is a cleaner way to express this?

  3. Is there any more elegant approach to this entirely that I’m not thinking of? Did I use Sequence too early, or should I have not used it at all?

I am (obviously) using Java – and would prefer not to use TypedActors, but would love all feedback!

Thank you very much for your time-

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:38:56+00:00Added an answer on May 28, 2026 at 1:38 am

    Something like this?

    final ActorRef cacheSender = getSender();
    Future<List<Object>> futureStatuses = sequence(statuses, ...);
    futureStatuses.onComplete( new Procedure2<Throwable, List<Object>>() {
      public void apply(Throwable t, Object r) {
        if(t != null) cacheSender.tell("ohnoes");
        else cacheSender.tell(r);
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, so this question probably isn't Silverlight specific. I have a silverlight 2 page
This is confusing me, so this question will probably be confusing. I have a
This is probably a very easy question. Hey I'm a student and relatively new
This question is probably for MySQL experts and admins that have done this sort
This is a question I probably should have asked sooner but didn't in my
This is probably a simple question for you JAVA experts, but I'm relatively new,
This question probably is based on my lack of understanding of the role of
This question would probably apply equally as well to other languages with C-like multi-line
This question is probably better phrased: how does running a Java server on a
I know this question is probably stoopid. But I just don't want to cause

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.