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 8628119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:27:21+00:00 2026-06-12T08:27:21+00:00

I have followed this tutorial: http://doc.akka.io/docs/akka/2.0/intro/getting-started-first-scala.html Basically there is a Master actor which responds

  • 0

I have followed this tutorial: http://doc.akka.io/docs/akka/2.0/intro/getting-started-first-scala.html

Basically there is a Master actor which responds to these two messages:

def receive = {
    case Calculate => {
      //....
    }
    case Result(value) => {
      //....
    }
}

We send the message “Calculate” and after several “Result”s (from the slave actors) we have the correct calculation

Now I am inside an action of a play2 controller and I am using this:

val promise = (master ? Calculate)(10.seconds).mapTo[String].asPromise

Unfortunately (obviously) I get nothing because Calculate message does reply with a message to the sender.

I would like to somehow make the Akka Actor wait…. and when the computation is complete to send a message back to the sender.

But how?… Unless I am modelling it in the wrong way!

  • 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-06-12T08:27:22+00:00Added an answer on June 12, 2026 at 8:27 am

    You should either forward the message to the slaves (which keeps the same sender), or include the sender in the message to the slaves. For example:

    def receive = {
      case Calculate => slave ! CalculateWithSender(sender)
    
      case res @ Result(value, originalSender) =>        
        val result = resultMap(originalSender) + res   // assuming results are just added
        resultMap += (originalSender -> result) 
        if (resultsAreFinished(originalSender))    
          originalSender ! result
    }
    

    or

    def receive = {
      case Calculate => slave.forward(Calculate)
    
      case res @ Result(value, originalSender) => 
        val result = resultMap(originalSender) + res   // assuming results are just added 
        resultMap += (originalSender -> result) 
        if (resultsAreFinished(originalSender))    
          originalSender ! result
    }
    

    or

    def receive = {
      case Calculate => slave.tell(Calculate, sender)
    
      case res @ Result(value, originalSender) => 
        val result = resultMap(originalSender) + res   // assuming results are just added 
        resultMap += (originalSender -> result) 
        if (resultsAreFinished(originalSender))    
          originalSender ! result
    }
    

    I’m not familiar with Play promises, but ? (ask) returns a Akka Future. If .asPromise converts an Akka Future to a Play Promise then you’re set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have followed this tutorial http://netbeans.org/kb/docs/websvc/gs-axis.html and successfully created the web service. When i
I have followed this tutorial: http://www.phpjabbers.com/how-to-make-a-php-calendar-php26-6.html#comments to make a very basic calendar. My aim
I have followed this tutorial to create the first azure application http://msdn.microsoft.com/en-us/WAZPlatformTrainingCourse_IntroToWindowsAzureLabVS2010 Because after
I have followed this tutorial ( http://developer.android.com/resources/tutorials/views/hello-tabwidget.html ) and completed the task and it
Hi have followed this tutorial using Core plot framework http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application My project compiles, but
I have followed this guide: http://maven.apache.org/guides/plugin/guide-java-plugin-development.html I have created a maven-plugin project hello-maven-plugin with
I have followed this tutorial to get my ListView populating data -- http://android.amberfog.com/?p=296 .
I am a new facebook application deverloper. I followed this tutorial: http://www.adobe.com/devnet/facebook/articles/video_facebook_quick_start.html but I
I am new to Google Web Toolkit. I followed the tutorial given on http://code.google.com/webtoolkit/doc/latest/tutorial/gettingstarted.html
Followed this tutorial on getting autocomplete for CI to work with Eclipse http://taggedzi.com/articles/display/autocomplete-eclipse-codeigniter-2 -

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.