actor

Setting up Parent-Child Actor in Play Framework

佐手、 提交于 2019-12-25 08:18:06
问题 I just started working on Play Framework + Akka. I have one Parent Actor and one child Actor(in future it can exceed). I am making an Api call from a controller and expecting a response from child actor. NotificationController: @Singleton public class NotificationController extends Controller{ final ActorRef commActor; @Inject public NotificationController(ActorSystem system) { commActor = system.actorOf(CommActor.props, "comm-actor"); } public CompletionStage<Result> communicate(int isDirect

Java - Libgdx : Keep actor's position even screen's resolution changes

♀尐吖头ヾ 提交于 2019-12-25 08:09:13
问题 issue is next one: my game is built for 1080x1920 pixels screen but if I run it in other resolutions my actors' position is switching. Some pictures if you haven't understood: ~> original resolution ~> other resolution I looked for an answer for days in Google, Stackoverflow, forums, couldn't find the right answer for my problem, here's my code: public class PlayScreen implements Screen { private Main game; private Stage stage; Music music; Sound sound; private class MenuGame extends Actor {

Scala futures creating infinity threads in actors

℡╲_俬逩灬. 提交于 2019-12-25 07:58:32
问题 I am using futures and timeouts inside an actor to avoid system to wait to long for a command to execute: val _output = future { "myCommand.sh" !! } output = try { Await.result(_output, 3 minutes) } catch { case e: TimeoutException => { LOG.warn(s"Timeout for command. Will return empty.") "" } } System.out.println("Number of active threads from the given thread: " + Thread.activeCount()); I run this code hundreds of times from different actors. I am noticing that the number of running threads

Scala futures creating infinity threads in actors

拟墨画扇 提交于 2019-12-25 07:57:25
问题 I am using futures and timeouts inside an actor to avoid system to wait to long for a command to execute: val _output = future { "myCommand.sh" !! } output = try { Await.result(_output, 3 minutes) } catch { case e: TimeoutException => { LOG.warn(s"Timeout for command. Will return empty.") "" } } System.out.println("Number of active threads from the given thread: " + Thread.activeCount()); I run this code hundreds of times from different actors. I am noticing that the number of running threads

AKKA Actor创建

白昼怎懂夜的黑 提交于 2019-12-25 03:25:26
Actor 类定义 Actor 类需要继承 AbstractActor 类 实现 createReceive 方法,绑定各类actor收到不同类型消息对应处理不同业务逻辑 默认提供了 ReceiveBuilder 类辅助创建 Receive 对actorOf的调用返回ActorRef的实例。这是 Actor 实例的句柄,也是与之交互的 唯一 方法。 ActorRef是不可变的,并且与它所表示的 Actor 有一对一的关系。ActorRef也是可序列化的, 序列化通过网络发送它,并在远程主机上使用它,并且它仍然在网络上表示原始节点上的同一个 Actor。 Actor的层级关系 Actor的层级关系类似树模式 谁创建谁管理原则: ActorSystem 创建就由ActorSystem负责监控管理(重启,异常,恢复等) Actor中创建另外的Actor,则创建者看做为父级,负责监控管理它创建出来的actor Actor 生命周期 actorOf -> preStart -> start -> receive -> stop -> postStop 另外: reRestart()默认行为是在重启(restarting)之前,它会终止所有的children actors(这个过程是递归的)。postRestart()则发生在重启成功之后。当然,方法都可以重写这两个方法以改变其行为。

Keeping references to two actors

心不动则不痛 提交于 2019-12-25 02:06:34
问题 I am making a little 2 player game that will work over the network with actors. Each client sends a message to the server to join and I want to keep references to the senders at that point, but when the second player joins it overwrites my reference to the first one: case class JoinMsg class Server(port: Int) extends Actor { var client1: OutputChannel[Any] = null var client2: OutputChannel[Any] = null def act() { alive(port) register('Server, self) while (true) { receive { case JoinMsg => if

Overriding behavior of actor on receipt of PoisonPill

自古美人都是妖i 提交于 2019-12-24 22:29:28
问题 I have an actor that is mysteriously dying, and I think the cause may be that someone is sending the actor a PoisonPill. Is there a way for me to override the behavior of an actor when it receives a PoisonPill so that it logs the sender and the fact that it just received a PoisonPill? That is, of course, in addition to stopping the actor. I am using 2.4.16, and in this version, PoisonPill behavior appears to be defined in a class called ActorCell. The problem is that this class is private and

How to manage actor shutdown in a singleton ActorSystem

橙三吉。 提交于 2019-12-24 19:05:49
问题 I have a singleton actor system in my application, and this works perfectly fine except that when the same application is loaded and unloaded inside the same JVM for testing, I have an error because I try, in my startup procedure, to recreate an actor which already exists. As a result I get an akka.actor.InvalidActorNameException because the Actor name is not unique. I am looking for a way to smoothly shutdown the actors depending on the actor systems without shutting down the actor system

Simple Akka mailbox configuration to discard overflowing messages

放肆的年华 提交于 2019-12-24 17:12:13
问题 I have a system with 2 actors, which share the same configuration. This desired configuration is: "the mailbox should have a max capacity of 1 message, and any overflowing message should be discarded". What is the easiest way to set this up? I have tried putting the following in (Play Framework's) application.conf : akka.actor.default-mailbox { mailbox-type = "akka.dispatch.BoundedMailbox" mailbox-capacity = 1 } But it doesn't work: the actor's mailbox still piles up messages when busy, and

Akka Actor Messaging Delay

。_饼干妹妹 提交于 2019-12-24 01:40:25
问题 I'm experiencing issues scaling my app with multiple requests. Each request sends an ask to an actor, which then spawns other actors. This is fine, however, under load(5+ asks at once), the ask takes a massive amount of time to deliver the message to the target actor. The original design was to bulkhead requests evenly, but this is causing a bottleneck. Example: In this picture, the ask is sent right after the query plan resolver. However, there is a multi-second gap when the Actor receives