actor

Type safe Scala actors

老子叫甜甜 提交于 2019-12-03 02:27:08
Is there any way to specify what type of message an actor can accept and give a compile error if anything tries to send it some other type? tenshi Not sure whether it answers your question, but I hope it will give you some ideas. Maybe you are searching for something like Typed Actors from Akka project: The Typed Actors are implemented through Typed Actors . It uses AOP through AspectWerkz to turn regular POJOs into asynchronous non-blocking Actors with semantics of the Actor Model. E.g. each message dispatch is turned into a message that is put on a queue to be processed by the Typed Actor

Design patterns for Agent / Actor based concurrent design [closed]

北战南征 提交于 2019-12-03 02:22:27
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . Recently i have been getting into alternative languages that support an actor/agent/shared nothing architecture - ie. scala, clojure etc (clojure also supports shared state). So far most of the documentation that I have read focus around the intro level. What I am looking for

Using Actors instead of `synchronized`

你说的曾经没有我的故事 提交于 2019-12-03 02:01:44
Every time I read about using synchronized in Scala the author will usually mention that Actors should be used instead ( this for example). While I understand roughly how actors work I'd really like to see an example of Actors being used to replace Java's synchronized method modifier (by this I mean its Scala equivalent - the synchronized block) in a piece of code. Modifying the internals of a data structure for instance would be nice to see. Is this a good use of Actors or have I been misinformed? Actors guarantee that only a single message will be handles at time so that there will not be

Akka Actor ask and Type Safety

爱⌒轻易说出口 提交于 2019-12-03 01:45:15
How can I use Akka Actor ask and maintain type safety? or avoid using ask in favour of tells? When calling ? or ask on an Akka Actor, a Future[Any] is returned and I have to do an explicit cast via future.mapTo[MyType] . I don't like losing this type safety. If I use Futures directly (with no actors) I can explicitly return Future[MyType] and maintain type safety. My specific use case involves an actor delegating it's message to two child actors and then aggregating the results from those actors and returning that to the parent's sender. My parent's receive method looks similar to this

面向对象设计原则、设计模式与动态类型语言

有些话、适合烂在心里 提交于 2019-12-03 01:36:41
在阅读 clean architecture 的过程中,会发现作者经常提到 recompile redeploy ,这些术语看起来都跟静态类型语言有关,比如Java、C++、C#。而在我经常使用的python语言中,是不存在这些概念的。于是,在阅读的时候就会有一个疑惑,《clean architecture》中提到的各种原则,比如SOLID,是否对动态类型语言 -- 如python -- 同样适用? SOLID是OOP的指导原则,更具指导性的应该是各种设计模式,GOF经典的 Design Patterns: Elements of Reusable Object-Oriented Software 也是用C++来举例的,那么这些经典设计模式有多少是适用于动态语言如python的呢?本文记录对这些问题浅薄的思考,如果有认知错误的地方,还请大家不吝指教。 本文地址: https://www.cnblogs.com/xybaby/p/11767100.html SOLID SOLID是模块(module)设计的指导原则,有以下五个原则组成 SRP(Single responsibility principle):单一职责原则,一个module只有一个原因修改 OCP(Open/closed principle):开放-关闭原则,开放扩展,关闭修改 LSP(Liskov

Akka in Scala, exclamation mark and question mark

你说的曾经没有我的故事 提交于 2019-12-03 01:34:14
问题 What is the difference between exclamation mark ( ! ) and question mark ( ? ) when sending messages to Actors? myActor ! Hello(value1) myActor ? Hello(value1) 回答1: Shamelessly copied [awesome] official doc (look Send messages section for more): Messages are sent to an Actor through one of the following methods. ! means “fire-and-forget”, e.g. send a message asynchronously and return immediately. Also known as tell . ? sends a message asynchronously and returns a Future representing a possible

TaskManager was lost/killed

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When I am trying to run the flink job in standalone cluster I get this error: java.lang.Exception: TaskManager was lost/killed: ResourceID{resourceId='2961948b9ac490c11c6e41b0ec197e9f'} @ localhost (dataPort=55795) at org.apache.flink.runtime.instance.SimpleSlot.releaseSlot(SimpleSlot.java:217) at org.apache.flink.runtime.instance.SlotSharingGroupAssignment.releaseSharedSlot(SlotSharingGroupAssignment.java:533) at org.apache.flink.runtime.instance.SharedSlot.releaseSlot(SharedSlot.java:192) at org.apache.flink.runtime.instance.Instance

Akka-Http 2.4.9 throws java.lang.NoClassDefFoundError: akka/actor/ActorRefFactory exception

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to build a simple web service with Akka-http. I followed this guide: http://doc.akka.io/docs/akka/2.4.9/scala/http/low-level-server-side-api.html and everything works fine, when I run sbt run. When I execute java -jar PROJECT.jar it returns: Exception in thread "main" java.lang.NoClassDefFoundError: akka/actor/ActorRefFactory at WebServer.main(WebServer.scala) Caused by: java.lang.ClassNotFoundException: akka.actor.ActorRefFactory at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass

Is passing around ActorRef to other Actors good or bad ?

别说谁变了你拦得住时间么 提交于 2019-12-03 01:15:05
I'm trying to figure out if my usage of passing Akka ActorRef around to other actors is not an anti-pattern. I've a few actors in my system. Some are long lived ( restClientRouter , publisher ) and some die after that they have done the work ( geoActor ). The short-lived actors need to send messages to the long-lived actors and therefore need their ActorRef s. //router for a bunch of other actors val restClientRouter = createRouter(context.system) //publishers messages to an output message queue val publisher: ActorRef = context.actorOf(Props(new PublisherActor(host, channel)), name = "pub

What is the difference between Typed and UnTyped Actors in Akka? When to use what?

北城以北 提交于 2019-12-03 01:12:30
I have tried to read the Akka documentation to find out the exact difference between Typed and Untyped actors. When to use what? I am not sure what I'm missing. Can somebody point me to something relevant or provide an answer to this question here itself? UntypedActor is simply the name for Actor but as the Java API. I'm very surprised that the documentation doesn't suffice: Java: http://akka.io/docs/akka/1.2/java/typed-actors.html http://akka.io/docs/akka/1.2/java/untyped-actors.html Scala: http://akka.io/docs/akka/1.2/scala/typed-actors.html http://akka.io/docs/akka/1.2/scala/actors.html The