akka

Akka Scala actor scheduled message does not appear to fire

南笙酒味 提交于 2020-01-15 08:26:10
问题 In experimenting with Akka actors, I cooked up a use case which doesn't quite work as expected. I've defined an actor, MyActor which receives a "start" message. This message kicks off a scheduler which should relays a message "request" to it self every 1 second . Here's the code: import akka.actor._ import scala.concurrent.Await import scala.concurrent.duration._ import akka.pattern.gracefulStop import scala.concurrent.ExecutionContext.Implicits.global object ScheduledActors { def main(args:

Akka Scala actor scheduled message does not appear to fire

核能气质少年 提交于 2020-01-15 08:26:03
问题 In experimenting with Akka actors, I cooked up a use case which doesn't quite work as expected. I've defined an actor, MyActor which receives a "start" message. This message kicks off a scheduler which should relays a message "request" to it self every 1 second . Here's the code: import akka.actor._ import scala.concurrent.Await import scala.concurrent.duration._ import akka.pattern.gracefulStop import scala.concurrent.ExecutionContext.Implicits.global object ScheduledActors { def main(args:

Play framework [2.5.0 java] - Blocked netty-event-loop threads resulting in timeout

一个人想着一个人 提交于 2020-01-14 19:38:46
问题 We have just upgraded from Play framework 2.4.3 to 2.5.0 (java). However, after upgrading, our tests start getting timeout after a couple of minutes. Before the upgrade they ran for an hour without errors. It looks like some threads are getting blocked, and the system simply stops responding. I am running a smaller version of the load test locally on my machine, with Yourkit java profiler. Initially, there are 16 netty-event-loop threads started. After about a minute, I can see that they have

How to integrate akka streams kafka (reactive-kafka) into akka http application?

只愿长相守 提交于 2020-01-14 06:42:11
问题 I have a basic scala akka http CRUD application. See below for the relevant classes. I'd simply like to write an entity id and some data (as json) to a Kafka topic whenever, for example, an entity is created/updated. I'm looking at http://doc.akka.io/docs/akka-stream-kafka/current/producer.html, but am new to scala and akka, and unsure of how to integrate it into my application? For example, from the docs above, this is the example of a producer writing to kafka, so I think I need to

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

Create actor on any unspecified/random node in cluster

*爱你&永不变心* 提交于 2020-01-13 16:45:14
问题 It is possible to programmatically create an actor on a remote node, if you specify the exact node. However, I would like to simply ask the actor system to create an actor on a random, or perhaps the least utilised node. Is it possible to create an actor on any remote node given an optional node role? 回答1: In Akka 2.3 you should use Cluster Aware Routers All routers can be made aware of member nodes in the cluster, i.e. deploying new routees or looking up routees on nodes in the cluster. So

How can I use and return Source queue to caller without materializing it?

前提是你 提交于 2020-01-13 10:53:14
问题 I'm trying to use new Akka streams and wonder how I can use and return Source queue to caller without materializing it in my code ? Imagine we have library that makes number of async calls and returns results via Source . Function looks like this def findArticlesByTitle(text: String): Source[String, SourceQueue[String]] = { val source = Source.queue[String](100, backpressure) source.mapMaterializedValue { case queue => val url = s"http://.....&term=$text" httpclient.get(url).map

How can I use and return Source queue to caller without materializing it?

ぃ、小莉子 提交于 2020-01-13 10:50:07
问题 I'm trying to use new Akka streams and wonder how I can use and return Source queue to caller without materializing it in my code ? Imagine we have library that makes number of async calls and returns results via Source . Function looks like this def findArticlesByTitle(text: String): Source[String, SourceQueue[String]] = { val source = Source.queue[String](100, backpressure) source.mapMaterializedValue { case queue => val url = s"http://.....&term=$text" httpclient.get(url).map

Is it possible to Autoscale Akka

淺唱寂寞╮ 提交于 2020-01-11 06:34:05
问题 I need an Akka cluster to run multiple CPU intensive jobs. I cannot predict how much CPU power I need. Sometimes load is high, while at other times, there isn't much load. I guess autoscaling is a good option, which means, example: I should be able to specify that I need minimum 2 and maximum 10 Actors. The cluster should scale up or down along with a cool off period as load goes up or down. Is there a way to do that? I am guessing, maybe one can make an Docker image of the codebase, and

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