I have the following stateful Actor

class StudentActor extends Actor with ActorLogging{
 
  var student:Student = Student(id,firstName,lastName)

  implicit val executionContext = Try {
    context.system.dispatchers.lookup("blocking-code-dispatcher")
  }.getOrElse(context.system.dispatcher)


  override def receive = {

    case UpdateStudent(_, c) =>
      Future[Student] {

        val updatedStudent = student.copy(counter = student.counter + c)
        student = updatedStudent
        log.info(sender().toString())
        updatedStudent
      }(executionContext).map(updatedStudent => sender() ! updatedStudent)

    case GetStudent(id,_) => sender() ! student

  }
}



When I try to use ask pattern to update this student from main method, I'm 
receiving timeout 


holder.ask(UpdateStudent("1")).mapTo[Student].foreach(println(_))


However, if I remove Future method and using the following code it works like 
charm:


  case UpdateStudent(_, c) =>        val updatedStudent = student.copy(counter 
= student.counter + c)

        student = updatedStudent
        log.info(sender().toString())
        updatedStudent

        sender() ! updatedStudent


    Why using Future in partial method causes ask timeout? 

I believe this is something stupid, but I can't figure it out :) 

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to