The below *minimum example* shows some very simple actor code that's not working as expected.
I'm setting the value for "name" and for "heartbeatSchedule", but in postStop they are both set to their initial values and not to the values I set. This feels like a threading problem, but it's that exactly what the Actor should be helping me avoid? Pastie is http://pastie.org/9572947# if that's easier to read. Best, Hamilton class ExampleProblemActor() extends Actor { var name:String = "" var heartbeatSchedule: Cancellable = null override def postStop = { // At this point, name == "" and heartbeatSchedule==null. Why? info(s"Name is '$name'") if (heartbeatSchedule != null) heartbeatSchedule.cancel else debug("Heartbeat schedule was null") } override def preStart() { implicit val system = context.system val boot = future { info(s"Waiting for my process to come online") if (false == ps.wait(ID, 200 second)) throw new IllegalStateException("Not online") } boot onSuccess { case _ => heartbeatSchedule = system.scheduler.schedule(0 seconds, 1 seconds, self, DoHeartbeat) // heartbeatSchedule != null here - I checked } } def receive = { case DoHeartbeat => { <snip> } case _ => { info(s"Received unknown message") } } def build(): (Process, String) = { info(s"Building and starting") var hostname = "hostname".!!.stripLineEnd; name = s"$hostname-2345" // name != "" here info(s"Building $name") <snip> } } -- >>>>>>>>>> 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
