actor

How to use pipeTo in AKKA correctly

我怕爱的太早我们不能终老 提交于 2020-01-14 04:55:10
问题 Hi I have two examples below within the receive method of an actor: First one does not cache the sender actor for piping val futureV = //Some function call that returns a Future futureV.pipeTo(sender) Second one takes the sender in a val first val currentS=sender val futureV = //Some function call that returns a Future futureV.pipeTo(currentS) My question is which one is the correct way to code and why? 回答1: They are the same. The sender is not going to change. pipeTo takes its argument by

Does it make sense to use a pool of Actors?

拈花ヽ惹草 提交于 2020-01-13 08:36:28
问题 I'm just learning, and really liking, the Actor pattern. I'm using Scala right now, but I'm interested in the architectural style in general, as it's used in Scala, Erlang, Groovy, etc. The case I'm thinking of is where I need to do things concurrently, such as, let's say "run a job". With threading, I would create a thread pool and a blocking queue, and have each thread poll the blocking queue, and process jobs as they came in and out of the queue. With actors, what's the best way to handle

Asynchronous http requests using Netty and Scala actors

ぐ巨炮叔叔 提交于 2020-01-12 05:35:11
问题 Asynchronous http requests using Netty and Scala actors Hey hope someone can give me a hand with this. I am trying to use the Scala Actors and Netty.io libraries to get make asynchronous http requests. (Yes I know Scala actors are being deprecated but this is a learning exercise for me) I have written an actor HttpRequestActor that accepts a message in the form of a case class RequestPage(uri:URI). When it receives the message it creates the necessary Netty objects need to make a http request

《Unreal Engine4 Scripting with C++ CookBook》:Chapter 4: Actors and Components

末鹿安然 提交于 2020-01-11 02:52:22
Creating a custom Actor in C++ ---本节讲解如何创建一个继承子Actor类的子类。借助UE wizard十分简单地即可创建。 并介绍了一些关于Actor的基本概念。 开发UE项目时,虽然UE提供了一些不同的Actor,但是难免需要创建自己的个性化的Actor来适应不同的需求:: 使用UE的wizard的步骤: 对上面生成的代码的讲解:(UE reflection system?) Instantiating an Actor using SpawnActor 来源: CSDN 作者: 蚓无爪牙之利 链接: https://blog.csdn.net/qq_35865125/article/details/103830669

OAuth 2 服务的 Akka 实现:access_token 管理

倖福魔咒の 提交于 2020-01-10 15:51:22
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 实现一个 OAuth 2 服务有几个核心点: OAuth 2 协议解析 连接的用户可能很多,系统需支持横向扩展 每个连接用户的 access_token 的状态控制:有效期控制 服务要支持容错、可恢复、可扩展、高并发等特性 使用 Akka 来实现 OAuth 2 服务会发现逻辑非常的清晰,且能很好的实现以上几个核心点。 每个连接用户或 access_token 可抽像为一个 Actor ,这样多个连接用户或 access_token 即可并发访问。在 Actor 内部可以管理过期时间等状态。 使用 akka-cluster-sharding 我们可以实现连接用户的集群部署、横向扩展。而 akka-persistence 提供 EventSourcedBehavior 为 Actor 添加了持久化能力,这实现了可恢复特性。通过使用 Akka Cluster 机制,可以减少对外部缓存系统的依赖。 Akka Actor提供了监管机制,这样我们可对错误快速响应,实现了容错性。 access_token 在 Akka 中通过 Actor 模型来设计 access_token 有两种主要方案: 每个 access_token 一个 Actor,通过 ClusterSharding 来水平扩展,将 Akka Actor

Interleaving of Orleans tasks

久未见 提交于 2020-01-05 08:36:29
问题 There is a question here where Orleans task execution in context of ContinueWith is discussed. I modified the example a bit more to check if two tasks of the same grain in Orleans can be made to interleave without the [Reentrant] flag. The entire code is here. The highlights of the code are as follows: // Client code var hashGenerator = client.GetGrain<IHashGeneratorGrain>(0); Console.WriteLine("Client making a call"); hashGenerator.Call_A_ToTemp(); await Task.Delay(10000); hashGenerator.Call

Akka: waiting for multiple messages

血红的双手。 提交于 2020-01-05 04:41:04
问题 Hi akka gurus:) Can you guide me in this one? What I'm trying to do - Actor A asks Actor B for a message and wait's for one to arrive back. But, somehow Actor B gives back to A not one message, but 4 of them. Actor A Future completes properly, but 3 of rest messages are counted as dead letters. Why? Is this right? I mean, Actor A has a proper handler, why the letters are dead then? :-( [INFO] [11/22/2013 22:00:38.975] [ForkJoinPool-2-worker-7] [akka://actors/user/a] Got result pong [INFO] [11

Sending messages to functions in Scala

拥有回忆 提交于 2020-01-03 13:40:08
问题 I'm working my way through Bruce Tate's Seven Languages in Seven Weeks and am having a hard time understanding his implementation of sizer.scala (Scala: Day 3). In particular, consider the following Singleton object object PageLoader { def getPageSize(url : String) = Source.fromURL(url).mkString.length } and the following method that, using actors, calculates the number of characters in each web page given by the urls array. def getPageSizeConcurrently() = { val caller = self for(url <- urls)

Discard all messages except the last one in a Scala actor

ε祈祈猫儿з 提交于 2020-01-03 03:21:08
问题 I have a SwingWorker actor which computes a plot for display from a parameters object it gets send; then draws the plot on the EDT thread. Some GUI elements can tweak parameters for this plot. When they change I generate a new parameter object and send it to the worker. This works so far. Now when moving a slider many events are created and queue up in the worker's mailbox. But I only need to compute the plot for the very last set of parameters. Is there a way to drop all messages from the

Reply is not transmitted back to the 'client'-actor

丶灬走出姿态 提交于 2020-01-02 10:02:58
问题 I've an unexpected behavior when using remote actors. I've a server and a 'client'. The client sends a message to the server actor and the server replies. When I use the '?' operator everything works as expected. I get the answer back from the server. The server: class HelloWorldActor extends Actor { def receive = { case msg => self reply (msg + " World") } } object Server extends App{ Actor.remote.start("localhost",2552); Actor.remote.register("hello-service",Actor.actorOf[HelloWorldActor])