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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:18:09+00:00 2026-05-25T21:18:09+00:00

How do I run 2 Akka actors with the caller sending the consumer a

  • 0

How do I run 2 Akka actors with the caller sending the consumer a message every n seconds?
As there are no loop-react methods as in the Scala.Actors library I am stuck
somehow, the following will not compile and produces:

overriding method receive in trait Actor of type =>
Caller.this.Receive; method receive has incompatible type

object Foo {
  def init() {
    actorOf[Caller].start()
    actorOf[Consumer].start()
  }
}

class Caller extends Actor {

  def receive {
    while (true) {
      self ! "msg"
      Thread.sleep(1000)
    }
  }
}

class Consumer extends Actor {

  def receive = {
    case msg:String => doStuff()
    case e => _
  }
}
  • 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-25T21:18:10+00:00Added an answer on May 25, 2026 at 9:18 pm

    You’re missing the equals sign after receive in Caller. Without it, the method is defined as returning Unit (i.e. no useful value), and akka needs you to return a PartialFunction[Any,Unit] from receive.

    Now, to actually implement your logic in the idiomatic way, you probably want to use a ReceiveTimeout, like so:

    class Caller extends Actor {
      self.receiveTimeout = Some(1000)
    
      def receive = { 
        case ReceiveTimeout => 
          self ! "msg"
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I run MSIL inside Visual Studio or via Mdbg. Is there any way of
When using akka , I place akka.conf in src/main/resources . When I run through
I have a Scala application using Akka that receives REST requests, makes some operations
I would like to use Akka actors in Java. I downloaded the akka-1.0.zip and
We run full re-indexes every 7 days (i.e. creating the index from scratch) on
I'm attempting to get fault tolerant behavior in akka Actors. I am working on
So I've been playing with Akka Actors for a while now, and have written
I have been looking into scala and AKKA for managing an obviously parallelisable algorithm.
Is it possible to run AKKA on Java 1.5? I'm getting java.lang.UnsupportedClassVersionError: Bad version
Run out of ideas... I need to group all entries form database. There are

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.