private void Ready() { ColorConsole.WriteLineGreen("api's current state is Ready."); Receive <ProcessJobMessage>(job => { _currentJob = job; ColorConsole.WriteLineWhite($"Received Task {job.ID}.{job.Description} for processing."); // ask the coordinator for job _coordinator.Tell(new CanAcceptJobMessage(job.Description, job.ID, job.TimeOut)); // move to next state BecomeAsking(); }); Receive <JobCompletedMessage>(job => { // send response to client _currentJob.Client.Tell(job); ColorConsole.WriteLineGreen($"Task {job.ID} is completed by api."); }); Receive <JobFailedMessage>(job => { // send response to client _currentJob.Client.Tell(job); ColorConsole.WriteLineRed($"Task {job.ID} is failed."); }); }
protected override void PreRestart(Exception reason, object message) { ColorConsole.WriteLineWhite("Commander's PreRestart called because: {0} ", reason.Message); //kill off the old coordinator so we can recreate it from scratch ColorConsole.WriteLineWhite("kill off the old coordinator so we can recreate it from scratch"); _coordinator.Tell(PoisonPill.Instance); base.PreRestart(reason, message); }