akka

Akka - How many instances of an actor should you create?

ぐ巨炮叔叔 提交于 2020-01-30 13:54:12
问题 I'm new to the Akka framework and I'm building an HTTP server application on top of Netty + Akka. My idea so far is to create an actor for each type of request. E.g. I would have an actor for a POST to /my-resource and another actor for a GET to /my-resource. Where I'm confused is how I should go about actor creation? Should I: Create a new actor for every request (by this I mean for every request should I do a TypedActor.newInstance() of the appropriate actor)? How expensive is it to create

How to use custom executor in Akka dispatcher

为君一笑 提交于 2020-01-30 05:27:11
问题 I am trying to use a custom executor for a dispatcher in Akka. Specifically, I want to wrap an existing executor with my own (logging, debugging, etc.). I've looked at relevant parts of documentation: The default dispatcher can be configured, and is by default a Dispatcher with a “fork-join-executor”, which gives excellent performance in most cases. and specify using “executor” using “fork-join-executor”, “thread-pool-executor” or the FQCN of an akka.dispatcher.ExecutorServiceConfigurator (I

Spark的Rpct模块的学习

混江龙づ霸主 提交于 2020-01-26 22:00:02
Spark的Rpc模块是1.x重构出来可,以前的代码中大量使用了akka的类,为了把akka从项目的依赖中移除,所有添加了该模块。先看下该模块的几个主要的类 使用EA把该模块所有的类都添加进来了 要看懂该模块还是要先了解akka, akka有Actor和ActorRef两个类,一个用于接收消息,一个用于发送消息。正好对应该模块的RpcEndpoint和RpcEndpointRef两个类。 下面大致介绍下这几个类,附带一些scala的特性 1:RpcAddress 该类是一个case class, 用来表示主机名和端口号 , case class也可以添加方法,以前还以为不可以呢 它的伴生对象用于从URI,String等构造一个RpcAddress对象 2:RpcTimeout 表示一个超时时间,话说该类的职责有点乱,竟然还有下面的一个方法 def awaitResult[T](awaitable:Awaitable[T]): T ={ try{ Await.result(awaitable, duration) }catch addMessageIfTimeout } 在规定时间内返回对象, Await是scala并发库中的一个对象,result在duration时间片内返回Awaitable的执行结果,ready表示

Scala Akka - generics type in receive handler

家住魔仙堡 提交于 2020-01-24 22:13:17
问题 I am trying to get my head around on what is best way to code this implementation. To give you example, here is my DAO handler code looks like trait IDAOHandler[+T] { def create[U <: AnyRef: Manifest](content: U): Try[String] } class MongoDAOHAndler extends IDAOHandler[+T]... So I am creating actor that will handle all my persistence task that includes serializing the content and updating MongoDB database. So I am using akka and the trick is in receive method, how do i handle generics type

Akka dispatcher not configured exception in Play/Scala application

非 Y 不嫁゛ 提交于 2020-01-24 20:58:26
问题 I am doing a disk intensive operation and I want to use my own thread-pool for it and not the default one. I read the following link, and I am facing the exact same problem Akka :: dispatcher [%name%] not configured, using default-dispatcher But my config file is slightly different, I have tried the suggestion but it not working. My application.conf in play has the following jpa-execution-context { thread-pool-executor { core-pool-size-factor = 10.0 core-pool-size-max = 10 } } And then in my

Akka dispatcher not configured exception in Play/Scala application

狂风中的少年 提交于 2020-01-24 20:57:59
问题 I am doing a disk intensive operation and I want to use my own thread-pool for it and not the default one. I read the following link, and I am facing the exact same problem Akka :: dispatcher [%name%] not configured, using default-dispatcher But my config file is slightly different, I have tried the suggestion but it not working. My application.conf in play has the following jpa-execution-context { thread-pool-executor { core-pool-size-factor = 10.0 core-pool-size-max = 10 } } And then in my

What's the difference between using AbstractBehavior and AbstractActor to define Akka Actors?

こ雲淡風輕ζ 提交于 2020-01-24 19:58:13
问题 I've started learning Akka actors recently and seen actors defined in two ways. class Main extends AbstractBehavior<String> and class SomeActor extends AbstractActor I'm following the Java API and could someone explain the difference or point to article that does ? 回答1: class Main extends AbstractBehavior Is Akka Typed, which is the way to define Actor Behavior from Akka 2.6. It is in 2.5 but as experimental. class SomeActor extends AbstractActor Is for untyped Actors, named classic Actors as

How to escalate top-most supervisors in Akka?

扶醉桌前 提交于 2020-01-24 19:08:31
问题 I have the following top-level (“parent-most”) actor: // Groovy pseudo-code class Master extends UntypedActor { ActorRef child1 ActorRef child2 ActorRef child3 ActorRef backup @Override void onReceive(Object message) throws Exception { if(message instanceof Terminated) { Terminated terminated = message as Terminated if(terminated.actor != backup) { terminated.actor = backup } else { // TODO: What to do here? How to escalate from here? } } else { child1.tell(new DoSomething(message), getSelf()

AKKA: Painless Actor Error Notifications

十年热恋 提交于 2020-01-24 04:14:05
问题 Beautiful People Lifestyle A component BEAUTIFUL is using her internal akka.actor.Actor to do certain things.. ( such as "acting up" for example ) There are other MAN components that would really like to "interact" with the BEAUTIFUL When the BEAUTIFUL finds a MAN worthy, before "interacting" with him, she agrees to take in his phone number ( let's call it an ErrorHandler ), you know just to give him a call in case he left in the morning and forgot his Rolex on her bed side table The

disable akka.jvm-exit-on-fatal-error for actorsystem in java

大憨熊 提交于 2020-01-22 18:44:47
问题 I am using akka actor system for multi threading. It is working fine in normal use-cases. However, Akka is closing JVM on fatal error. Please let me know how I can configure Akka to disable "akka.jvm-exit-on-fatal-error" in java. Below is code. public class QueueListener implements MessageListener { private String _queueName=null; public static boolean isActorinit=false; public static ActorSystem system=null; private ActorRef myActor; public QueueListener(String actorId, String qName){ this.