akka

Should my Akka actors' properties be marked @volatile?

人走茶凉 提交于 2021-02-20 06:01:48
问题 This question looks similar to Should my Scala actors' properties be marked @volatile? but not sure that answer will be the same. As example, in case when the fork-join dispatcher was configured and actor's state wasn't marked by @volatile, is it guarantied that state of the actor will be propagated through the cache hierarchy from one core (or processor) to another if fork/join worker threads run on different cores (or processors)? P.S. Is it right that after JSR133 only one write/read

restapi(0)- 平台数据维护,写在前面

a 夏天 提交于 2021-02-19 01:46:01
在云计算的推动下,软件系统发展趋于平台化。云平台系统一般都是分布式的集群系统,采用大数据技术。在这方面akka提供了比较完整的开发技术支持。我在上一个系列有关CQRS的博客中按照实际应用的要求对akka的一些开发技术进行了介绍。CQRS模式着重操作流程控制,主要涉及交易数据的管理。那么,作为交易数据产生过程中发挥验证作用的一系列基础数据如用户信息、商品信息、支付类型信息等又应该怎样维护呢?首先基础数据也应该是在平台水平上的,但数据的采集、维护是在系统前端的,比如一些web界面。所以平台基础数据维护系统是一套前后台结合的系统。对于一个开放的平台系统来说,应该能够适应各式各样的前端系统。一般来讲,平台通过定义一套api与前端系统集成是通用的方法。这套api必须遵循行业标准,技术要普及通用,这样才能支持各种异类前端系统功能开发。在这些要求背景下,相对gRPC, GraphQL来说,REST风格的http集成模式能得到更多开发人员的接受。 在有关CQRS系列博客里,我以akka-http作为系统集成工具的一种,零星地针对实际需要对http通信进行了介绍。在restapi这个系列里我想系统化的用akka-http构建一套完整的,REST风格数据维护和数据交换api,除CRUD之外还包括网络安全,文件交换等功能。我的计划是用akka-http搭建一个平台数据维护api的REST-CRUD框架

MongoDB Reactive Streams run-time dependency error with Alpakka Mongo Connector ClassNotFoundException

天大地大妈咪最大 提交于 2021-02-17 06:31:07
问题 I'm trying to integrate the Alpakka Mongo Connector into an application that heavily relies on the Akka libraries for stream processing. The application utilizes Akka HTTP as well. I am encountering a dependency issue at run-time. In particular, I'm getting a NoClassDefFoundError for some kind of Success/Failure wrappers when I try to use the MongoSink.insertOne method provided by the Mongo connector. A full stack-trace: java.lang.NoClassDefFoundError: com/mongodb/reactivestreams/client

Akka系列(十):Akka集群之Akka Cluster

泪湿孤枕 提交于 2021-02-13 07:31:23
前言........... 上一篇文章我们讲了Akka Remote,理解了Akka中的远程通信,其实Akka Cluster可以看成Akka Remote的扩展,由原来的两点变成由多点组成的通信网络,这种模式相信大家都很了解,就是集群,它的优势主要有两点:系统伸缩性高,容错性更好。 集群概念 很多人很容易把分布式和集群的概念搞错,包括我也是,我一开始也以为它们两个是一样的概念,只是叫法不同而已,但其实不然,虽然它们在实际场景中都是部署在不同的机器上,但它们所提供的功能并不是一样的。举个简单的例子来看看它们之间的不同: 为了保持整个系列连续性,我又以抽奖为基础举一个例子: 假定我们现在抽奖流程包括,抽奖分配奖品和用户根据链接领取指定奖品,用户先抽奖然后获取奖品链接,点击链接填写相应信息领取奖品。 1.分布式: 我们现在把抽奖分配奖品和用户根据链接领取指定奖品分别部署在两台机器上,突然有一天很不幸,抽奖活动进行到一半,抽奖分配奖品那台机子所在的区域停电了,很显然,后续的用户参与抽奖就不能进行了,因为我们只有一台抽奖分配奖品的机子,但由于我们将领取奖品的业务部署在另一台机器上,所以前面那些中奖的用户还是可以正常的领取奖品,具体相关定义可参考《分布式系统概念与设计》中对分布式系统的定义。 2.集群: 现在我们还是有两台机器

Mutual Authentication in Scala with Akka

只谈情不闲聊 提交于 2021-02-10 15:14:12
问题 I would create a TLS Session in Scala using Akka with mutual authentication between a client and a server. I have created two CA certificate that have to trust the respective certificates incoming from the other part. Could you give me an exemple of how implement this? Thank you. 回答1: I created a github project which demonstrates mutual authentication with different kind of clients, including Akka. Please have a look here: https://github.com/Hakky54/mutual-tls-ssl It contains a full example

Akka HTTP Error Response entity was not subscribed after 1 second

谁说我不能喝 提交于 2021-02-08 05:41:54
问题 I am using Akka HTTP cachedHostConnectionPoolHttps pool to send requests as part of Akka Streams Flow: private val requestFlow: Flow[(HttpRequest, HelperClass), Either[Error, String], _] = Http().cachedHostConnectionPoolHttps(BaseUrl).mapAsync(1) { case (Success(HttpResponse(_, _, entity, _)), _) => Unmarshal(entity).to[String].map(response => { Right(response) }) case (Failure(ex), _) => Future(Left(Error(ex))) } For some reason not all request responses are being processed. Some results in

Akka HTTP Error Response entity was not subscribed after 1 second

谁都会走 提交于 2021-02-08 05:41:35
问题 I am using Akka HTTP cachedHostConnectionPoolHttps pool to send requests as part of Akka Streams Flow: private val requestFlow: Flow[(HttpRequest, HelperClass), Either[Error, String], _] = Http().cachedHostConnectionPoolHttps(BaseUrl).mapAsync(1) { case (Success(HttpResponse(_, _, entity, _)), _) => Unmarshal(entity).to[String].map(response => { Right(response) }) case (Failure(ex), _) => Future(Left(Error(ex))) } For some reason not all request responses are being processed. Some results in

Dynamically merge Akka streams

一曲冷凌霜 提交于 2021-02-08 04:12:40
问题 I’m trying to use Akka streams to build a pub sub bus in the following way: Publisher adds a source stream for the topic and subscribers specify a topic and get everything for that topic. However topic may be published by multiple Publishers, and both publisher and subscribers can join at any point. What I had in mind is to combine all sources and then return the filtered source to a subscriber. However as publishers may join at any point sources may be added after a subscription has been

Dynamically merge Akka streams

喜你入骨 提交于 2021-02-08 04:11:51
问题 I’m trying to use Akka streams to build a pub sub bus in the following way: Publisher adds a source stream for the topic and subscribers specify a topic and get everything for that topic. However topic may be published by multiple Publishers, and both publisher and subscribers can join at any point. What I had in mind is to combine all sources and then return the filtered source to a subscriber. However as publishers may join at any point sources may be added after a subscription has been

How to get an actor reference (ActorRef) from ActorFlow?

非 Y 不嫁゛ 提交于 2021-02-08 02:21:18
问题 According to the Play documentation on WebSockets the standard way to establish a WebSocket is to use ActorFlow.actorRef , which takes a function returning the Props of my actor. My goal is to get a reference to this underlying ActorRef , for instance in order to send a first message or to pass the ActorRef to another actor's constructor. In terms of the minimal example from the documentation, I'm trying to achieve this: class WebSocketController @Inject() (implicit system: ActorSystem,