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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:53:54+00:00 2026-05-22T22:53:54+00:00

I’m pretty new to Akka and couldn’t find the answer in the reference manual.

  • 0

I’m pretty new to Akka and couldn’t find the answer in the reference manual.

Suppose we have remote actors distributed in the cluster of 3 machines (A, B, C), where one actor lives on each machine and others have actorRef to 2 others, i.e.:

Machine A:
A (real actor)
-> B (ref)
-> C (ref)

Machine B:
-> A (ref)
B (real actor)
-> C (ref)

Machine C:
-> A (ref)
-> B (ref)
C (real actor)

Actor A executes following code:

bRef ! msg1
bRef ! msg2

Actor B executes following code in message handler:

case msg1 => 
    cRef ! msg3
    aRef ! msg4

Actor C executes following code in message handler:

case msg3 => 
    aRef ! msg5

Can I make the following assumptions (if any):

  1. actor B gets msg1 before it gets msg2

  2. actor A gets msg5 before it gets msg4

And the follow-up question which probably leads to understanding the above:
Is message sent by the ! operator through the network truly asynchronously or does it wait until the receiving mailbox gets it?
I.e. does the line

bRef ! msg1

block until actor B gets the message in its mailbox or does it spawn the thread which handles the delivery and continue executing

bRef ! msg2

before it even knows that actor B got msg1?

  • 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-22T22:53:55+00:00Added an answer on May 22, 2026 at 10:53 pm

    For (1) you have the guarantee that msg1 will be enqueued by the dispatcher before msg2. What actually happens once they are enqueued is really dependent on which dispatcher you use: http://akka.io/docs/akka/1.1.2/scala/dispatchers.html, but in your case then so long as B can accept both messages then it will always receive msg1 before msg2.

    For (2), no you do not have this guarantee. The ! method returns as soon as the dispatcher enqueues the message not when the message is accepted by the target actor’s mailbox. The sending is then done in another thread and is subject to all kinds of race conditions.

    Is message sent by the ! operator through the network truly asynchronously or does it wait until the receiving mailbox gets it?

    You can use a BoundedMailbox with local actors to show that enqueuing messages to dispatchers is asynchronous with !:

    class TestActor extends Actor {
      val mailboxCapacity = BoundedMailbox(capacity = 1)
      self.dispatcher = Dispatchers.newExecutorBasedEventDrivenDispatcher("test", 1, mailboxCapacity).build
    
      def receive = {
        case x: String => 
          Thread.sleep(1000)
          println("Received message")
        case _ => 
      }
    }
    
    val t = Actor.actorOf[TestActor]
    t.start()
    
    t ! "one"; t ! "two"; t ! "three"; println("Main thread");
    

    Prints:

    scala>     t ! "one"; t ! "two"; t ! "three"; println("Main thread");
    Received message
    Main thread
    
    scala> Received message
    Received message
    

    Which means that code execution in the main thread continues before you even know whether or not the message will ever be delivered. In this case the message send could easily have timed out if we set a pushTimeout on the dispatcher and made Thread.sleep wait for longer than the timeout.

    Compare this to using !!:

    scala>     t !! "one"; t !! "two"; t !! "three"; println("test");
    Received message
    Received message
    Received message
    test
    

    So, with this in mind. The way to achieve (2) would be:

    case msg1 =>
      cRef !! msg3
      aRef ! msg4 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
Specifically, suppose I start with the string string =hello \'i am \' me And
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.