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

  • Home
  • SEARCH
  • 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 9210507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:05:46+00:00 2026-06-18T01:05:46+00:00

Using Akka 2.1.0 I’m sending a message from one Actor ( ActorA ) to

  • 0

Using Akka 2.1.0 I’m sending a message from one Actor (ActorA) to another (ActorB) and expecting the returned message to be an Option[(String, String)]. ActorB has a val defined as an Enumeration and this is being returned as the second element of the Tuple result.
ActorA uses the Await.result().asInstanceOf[Option[(String, String)] pattern (I know this is bad blocking behavior, but don’t think this explains the behavior I’m seeing), and assigns the result to a val. Later when I try to pull out the second element of the Tuple result I get a scala.Enumeration#Val cannot be cast to java.lang.String cast exception. In previous versions of Akka this did not appear, and in Akka 2.1.0 I would expect the Await.result operation to blow up. Can anyone explain what is going on here?

object MyEnumeration extends Enumeration {
  type Enum = Value
  val Foo = Value("foo")
  val Bar = Value("bar")
}

case class ActorA extends Actor {
  implicit val timeout = Timeout(10000)
  val result = Await.result((ActorB ? MyMessage), timeout.duration).asInstanceOf[Option[(String, String)]]

  val validResult = result.get
  val validType = validResult._2 // this is of type Enumeration#Val not String

}

case class ActorB extends Actor {
  def myType = MyEnumeration.Foo
  def receive = {
  case MyMessage =>
      sender ! Option((validString, myType))
  }
}
  • 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-18T01:05:47+00:00Added an answer on June 18, 2026 at 1:05 am

    It didn’t actually work in Akka 2.0.3. As I understood, you parsed received message differently.

    // enum
    object E extends Enumeration { val a,b,c = Value }
    
    // send 
    case "Hello" => sender ! Some(("Hai", E.a))
    
    // works
    Await.result(rootActor ? "Hello", timeout.duration)
    .asInstanceOf[Option[(String, String)]] match {
      case a: Option[Tuple2[_, _]] => // diff is here 
        println("" + a.get._2)
        a.get._2
    }  
    
    
    // does not work
    Await.result(rootActor ? "Hello", timeout.duration)
    .asInstanceOf[Option[(String, String)]] match {
      case a: Option[Tuple2[String, String]] => // diff is here
        println("" + a.get._2)
        a.get._2
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Akka framework recommends using typed actor only for interacting with external code. However, standard
What has kept me from using Akka regularly (in Java) is a concern I
Let's say I have an actor like this (Using Akka 2.1 with Scala 2.10):
I have implemented an Actor system using Akka and its Java API UntypedActor. In
How can I use Akka Actor ask and maintain type safety? or avoid using
I wish to use the Akka actor modules. I am using Eclipse in Kubuntu.
I am using Akka for actor model programming with Scala, and in order to
I am using Akka FSM for handling state in my Actor. I want some
I am having some trouble using become in my Akka actor. Basically, my actor
Using akka 1.3.1, I was able to previously do something like this: Actor.remote.start(config.server.host, config.server.port)

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.