actor

Create an Akka actor remotely without a new ActorSystem

Deadly 提交于 2019-12-08 01:16:31
问题 I've been over the documentation several times now (http://doc.akka.io/docs/akka/2.1.4/scala/remoting.html) and through the example here (https://github.com/akka/akka/tree/master/akka-samples/akka-sample-remote) and through others, and I still can't figure out how to do what I want to do. The closest answer I've found is this: how to start remote actors in scala, but it seems much more inconvenient than I'd think it would be. I have a cluster of 12 machines to work on. I would like to

Can I extend actor in use case? [closed]

自作多情 提交于 2019-12-07 20:09:35
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . Can I extend actor in use case? for example I have "normal user" , "student user" and "teacher user"... every use case the "normal user" uses it ,by default the "student user" and "teacher user" use it too.. so

Akka: What happens when you tell an ActorRef and it expects you to ask?

烂漫一生 提交于 2019-12-07 19:26:37
问题 I have the following: val future = myActor ? Message And in my actor my receive message has something like this: sender ! Response If I do the following and ignore the response, is there any negative impact? myActor ! Message Maybe I'm just missing where it says this in the documentation. Is it like a method that returns a value and the caller doesn't assign the return value to anything? If I make that call from another actor is there going to be some weird threading issue or memory leaks

Akka and its Error Kernel

混江龙づ霸主 提交于 2019-12-07 11:40:33
问题 I am reading the Akka ( Java lib ) docs and need clarification on some of their own proclaimed Akka/Actor Best Practices. Actors should not block (i.e. passively wait while occupying a Thread) on some external entity...The blocking operations should be done in some special-cased thread which sends messages to the actors which shall act on them. So what does a code example of this look like in Akka/Java? If an Actor isn't an appriote place to put code that has to block, then what does satisfy

how to execute (exec) external system commands in Scala actor?

 ̄綄美尐妖づ 提交于 2019-12-07 10:34:28
to run an external command, I should import sys.process._ val result="ls a" ! then when use actor, I need to also use "!" to send message. So ! is defined both in actor and in process, but I need to use them both in the same code block, how to do that? I don't see the issue of Process and ActorRef both defining a method with the same name. An analog example would be class A { def ! = println("A") } class B { def ! = println("B") } val a = new A val b = new B a.! // "A" b.! // "B" There's no name collision or ambiguity at all. The only thing you have to worry about is the implicit conversion

Dead-letter in Akka Scala actors

倾然丶 夕夏残阳落幕 提交于 2019-12-07 08:44:38
问题 I have a very simple structure based on Akka actors in Scala, but I keep on receiving warnings about undelivered messages. This is the code for the main class, Collector is a separate class extending Actor: object Executor extends App { class ExecutorMaster extends Actor { def receive() = { case _ => Executor.actorSystem.actorOf(Props[Collector], name = "Collector") ! true } } val actorSystem = ActorSystem("ReadScheduler") private val app = actorSystem.actorOf(Props[ExecutorMaster], name =

Akka实战:分散、聚合模式

拈花ヽ惹草 提交于 2019-12-07 08:32:37
分散与聚合 :简单说就是一个任务需要拆分成多个小任务,每个小任务执行完后再把结果聚合在一起返回。 代码 http://git.oschina.net/yangbajing/akka-action 实例背景 本实例来自一个真实的线上产品,现将其需求简化如下: 传入一个关键词: key ,根据 key 从网上抓取相关新闻 可选传入一个超时参数: duration ,设置任务到期时必须反回数据(返回实际已抓取数据) 若超时到返回实际已爬取数据,则任务应继续运行直到所以数据抓取完成,并存库 设计 根据需求,一个简化的分散、聚合模式可以使用两个 actor 来实现。 NewsTask:接收请求,并设置超时时间 SearchPageTask:执行实际的新闻抓取操作(本实例将使用TimeUnit模拟抓取耗时) 实现 NewsTask https://github.com/yangbajing/akka-action/blob/master/src/main/scala/me/yangbajing/akkaaction/scattergather/NewsTask.scala override def metricPreStart(): Unit = { context.system.scheduler.scheduleOnce(doneDuration, self, TaskDelay) }

In which way is akka real-time?

南楼画角 提交于 2019-12-07 03:11:45
问题 At a couple of places there is state that akka is somehow "real-time". E.g.: http://doc.akka.io/docs/akka/2.0/intro/what-is-akka.html Unfortunately I was not able to find a deeper explanation in which way akka is "real-time". So this is the question: In which way is akka real-time? I assume akka is not really a real-time computing system in the sense of the following definition, isn't it?: https://en.wikipedia.org/wiki/Real-time_computing 回答1: No language built on the JVM can be real-time in

Execution context for futures in Actors

China☆狼群 提交于 2019-12-07 01:46:42
问题 I have a Actor, and on some message I'm running some method which returns Future. def receive: Receive = { case SimpleMessge() => val futData:Future[Int] = ... futData.map { data => ... } } Is it possible to pass actual context to wait for this data? Or Await is the best I can do if I need this data in SimpleMessage ? 回答1: If you really need to wait for the future to complete before processing the next message, you can try something like this: object SimpleMessageHandler{ case class

In AKKA does calling shutdown on a supervisor stop all the actors it's supervising?

情到浓时终转凉″ 提交于 2019-12-06 23:52:14
问题 Let's say I have a supervisor that has linked 2 actors. When my app shutsdown I want to shutdown those actors gracefully. Does calling supervisor.shutdown() stop all the actors or do I still need to stop my actors manually? gracias 回答1: Stopping a supervisor (calling Supervisor.stop() ) stops all linked (supervised) actors: final class SupervisorActor{ ... override def postStop(): Unit = shutdownLinkedActors However, when you want to shutdown all actors in the system gracefully, there's