Hi there, Read the docs on stopping actors please: http://doc.akka.io/docs/akka/snapshot/scala/actors.html#Stopping_actors E.g. it'd be context.stop(self) inside the actor.
The order in which you shut things down also does not really make much sense: - you shut down the entire actor system, - but then send a message to the actor (PoisonPill). Once the code is at that line the entire system is terminated so the message send won't ever do anything :) Hope this helps, read through the docs for a goo start IMO. Happy hakking -- Konrad `ktoso` Malawski Akka <http://akka.io> @ Lightbend <http://lightbend.com> On 17 November 2016 at 13:13:47, константин паляничка ( [email protected]) wrote: Hi... i am newes in akk and scala and i can not find answer for my problem. How i can terminate akka actor in this examplу ? import akka.actor.{Actor, ActorSystem, PoisonPill, Props, ActorLogging } import scala.concurrent.{Await, Future} import scala.util._ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration._ import akka.actor._ import org.jsoup.Jsoup case class Scrap(url:String) class Scrapper extends Actor with ActorLogging { def getDoc(url:String):org.jsoup.nodes.Document={ val user_agent:String ="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1" val response = Jsoup.connect(url).timeout(3000).ignoreContentType(true).userAgent(user_agent).execute() val contentType: String = response.contentType val doc = response.parse() doc } override def postStop() = { context.system.terminate } def receive = { case Scrap(url)=> println(s"scraping $url") val content = Future{ getDoc(url) } content onComplete { case Success(content) => println(content.title) //context.system.terminate() case Failure(content) => println("some error") context.system.terminate() } } } object main extends App{ val system = ActorSystem() val supervisor = system.actorOf(Props(new Scrapper )) for(i<-0 to 50 ) { supervisor ! Scrap("http://football.ua") } Await.result(system.whenTerminated, Duration.Inf) supervisor ! PoisonPill system.terminate } -- >>>>>>>>>> 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 https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout. -- >>>>>>>>>> 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 https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
