问题标签 [akka.net]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
2130 浏览

c# - 在典型的 MVC 应用程序中使用 Akka.NET。如何?

我有一个使用实体框架与数据库交互的典型 Web 应用程序。这是应用程序的分解。

  1. Demo.Core [包含日志记录(nlog 的东西)、助手类、系统范围的常量等]
  2. Demo.Entities [仅包含 Entity 框架实体或 edmx 文件 - 无上下文]
  3. Demo.Business [包含数据管理器、EF 上下文、使用 NRules 的业务规则、验证等]
  4. Demo.Web [包含作为前端的 MVC 应用程序]

现在我想在这个应用程序中使用 Akka.NET。我创建了一个封装 Akka System actor 的 Engine 类并创建了一个日志 actor (Demo.Core)。我认为引擎是一个类,它具有可以在系统范围内使用的发送功能,并且该功能决定哪个演员最适合处理消息。

但是,我无法决定如何根据 akka 管理数据上下文和实体类。

  1. 我应该有单独的 Actor 来检索每种类型的实体吗?还是一个 Actor 来检索所有实体?
  2. 我应该为不同角色设置多个具有不同上下文的参与者,例如 DBReaderActor 和 DBWriterActor 还是具有数据库上下文的单个参与者?
  3. 是否可以让引擎具有如上所述的单个发送功能,或者每个类都应该调用适当的参与者本身?
  4. 一个系统的参与者可以在多个程序集中吗?像 Demo.Core & Demo.Business?
  5. 如果我运行 Demo.Web 的两个实例,一个在 IIS 上,一个在 WebDev 上,它们会有 2 个独立的参与者系统还是一个单一的参与者系统(它们都使用相同的代码库)?

    我是 Akka.NET 的新手,所以请不要在回答时假设事情

0 投票
1 回答
1144 浏览

actor - 如何让演员睡觉?

我有一个演员正在执行一个永久循环,该循环正在等待数据的可用性进行操作。文档说 Actor 在一个非常轻量级的线程上运行,所以我不确定我是否可以在那个 Actor 上使用 thread.sleep() 方法。我的目标是不让那个演员消耗太多的处理能力。

那么我可以在 actor 内部使用 thread.sleep() 方法吗?

0 投票
1 回答
469 浏览

c# - 如何检测远程参与者断开连接(分离)?

我有包含一些 ServerActor 的服务器。该参与者接收 RegisterClient 消息并将 ActorRefs 添加到注册客户端列表中。

我也有多个客户端,每个客户端都包含应该在服务器上注册以进行进一步操作的 ClientActor。

处理客户端参与者断开连接的最佳模式是什么(例如由于网络故障)。我应该实现一些心跳消息还是 akka.net 包含开箱即用的东西?

0 投票
1 回答
501 浏览

akka.net - 在集群路由中回复 Ask

我正在创建一个项目,此时有一个演员(用户)通过一致的哈希组路由器调用另一个演员(音乐会)。一切正常,但我的问题是音乐会演员我无法回答询问消息。不知何故,消息丢失了,客户端什么也没有发生。我已经尝试了一切都没有运气:

  • Sender.Tell <-- 创建一个时间?发件人
  • 通过消息中的引用传递用户 IActorRef 并使用它。

这是完整的代码:https ://github.com/pablocastilla/AkkaConcert

主要细节如下:

用户演员:

客户端HOCON配置:

在后端:

演员已创建

音乐会演员消息处理

后端的 HOCON 配置:

谢谢!

0 投票
1 回答
169 浏览

akka - 用户的个人资料作为具有 akka.cluster 的演员。路由和创建

我想将 Akka.Cluster 用于简单的用户配置文件服务。很少有 http-api 服务实例会为一些带有用户配置文件持久角色(配置文件角色)的后端实例发送消息。每个 http-api 服务都可以为同一个 Profile Actor 发送消息,所以我应该使用 Consistent Hashing Group 路由器。但是如果我要使用组路由器,我应该为每个 Profile Actor 添加路由到组路由器,据我所知,这是不可能的。我不能使用池路由器,因为每个带有池路由器的 http-api 实例都会为一个用户创建自己的 Profile Actor。如何使用 akka.cluster 实现用户配置文件?也许在相同的情况下存在一些模式?

0 投票
1 回答
427 浏览

c# - Unable to communicate between actors in Akka.Cluster

I am having some problems in communicating between actors in Cluster.

My test project has this structure below.

TestJob [C# Console Project]

  • TestJobService.cs
  • TestJobActor

MainProject [C# Console Project] //Note: I configured this service as a seed node. I didn't use lighthouse.

  • MainService
  • JobManagerActor

Note: I don't want to put actors in Shared project or Main project. The actors that are supposed to do a test job should be under "TestJob" project.

I already followed this article http://getakka.net/docs/clustering/cluster-overview and video. I did enable Akka.Cluster based on the article. I am able to run both console projects but when I tried to "tell" from JobManagerActor to TestJobActor, it doesn't work. No error but doesn't work.

I have this config in MainProject.

Here is the code that I use for sending the message.

What am I missing? Thanks in advance.

Note: My test project with similar structure can be found here https://github.com/michaelsync/APMDemo . (VS2015 project)

One more question: Can we still use the actor selection when using cluster?

0 投票
2 回答
359 浏览

akka.net - 如何使 akka-tree 与 akka.net 集群一起工作?

我目前正在寻找 akka.net(.NET 版本)的可视化工具。我没有找到,所以我想知道是否有任何方法可以使 akka-tree(规模)和 akka.net 集群一起工作。我想如果两个框架都遵循相同的规范,那么它应该可以工作。是吗?

我尝试在 akka-tree 中问这个问题,但没有回应,所以我在这里试试运气。

https://github.com/nraychaudhuri/akka-tree/issues/15

我不熟悉规模,但我做了以下更改。

我尝试在我的 akka.net 示例中添加 UDP 配置,因为我认为这个可视化工具正在使用 UDP。

然后,我尝试更改此文件 akka-tree\visualizer\app\controllers\Application.scala 中的 IP 地址

但是,不起作用..知道如何使它起作用吗?谢谢!

更新:

我尝试使用 TCP 但不起作用。

当我访问网页“localhost:90000”时出现以下异常。我对Scale不熟悉,但我认为它与Scale安装有关。我确实在我的机器上安装了 scale 和 java..

[信息] 将 1 个 Scala 源代码编译到 D:\git\akka-tree\visualizer\target\scala-2.11 \classes... [信息] 播放 - 应用程序已启动 (Dev) [错误] 应用程序 -

!内部服务器错误,用于 (GET) [/] ->

java.lang.ExceptionInInitializerError: null at Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.appl y(routes_routing.scala:72) ~[na:na] at Routes$$anonfun$routes $1$$anonfun$applyOrElse$1$$anonfun$apply$1.appl y(routes_routing.scala:72) ~[na:na] at play.core.Router$HandlerInvokerFactory$$anon$13$$anon$14.call(Router. scala:217) ~[play_2.11-2.3.7.jar:2.3.7] 在 play.core.Router$Routes$TaggingInvoker.call(Router.scala:464) ~[play_2.11-2.3.7.jar: 2.3.7] 在 Routes$$anonfun$routes$1$$anonfun$applyOrElse$1.apply(routes_routing.scala:72) ~[na:na] 引起:java.net.SocketException:不是 java.net 的多播地址.MulticastSocket.joinGroup(Unknown Source) ~[na:1.8.0_51] at controllers.Application$.(Application.scala:16) ~[na:na] at controllers.Application$.(Application.scala) ~[na:na] at Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.appl y(routes_routing.scala:72) ~[na:na]在 Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.appl y(routes_routing.scala:72) ~[na:na] [error] application - 渲染默认错误页面时出错 scala.MatchError : java.lang.ExceptionInInitializerError (of class java.lang.Exce ptionInInitializerError) at play.api.GlobalSettings$class.onError(GlobalSettings.scala:148) ~[play y_2.11-2.3.7.jar:2.3.7]在 play.api.DefaultGlobal$.onError(GlobalSettings.scala:206) [play_2.11- 2.3.7.jar:2.3.7] 在 play.core.server.Server$class.logExceptionAndGetResult$1(Server.scala:63 ) [play_2.11-2.3.7.jar:2.3.7] 在 play.core.server.Server$$anonfun$getHandlerFor$4。apply(Server.scala:7 3) [play_2.11-2.3.7.jar:2.3.7] 在 play.core.server.Server$$anonfun$getHandlerFor$4.apply(Server.scala:7 1) [play_2 .11-2.3.7.jar:2.3.7] [错误] 应用程序 -

!内部服务器错误,对于 (HEAD) [/] ->

java.lang.NoClassDefFoundError: 无法在 Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.appl y(routes_routing.scala:72) ~[na:na 处初始化类控制器。 ] at Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.appl y(routes_routing.scala:72) ~[na:na] at play.core.Router$HandlerInvokerFactory$$anon$13$ $anon$14.call(Router.scala:217) ~[play_2.11-2.3.7.jar:2.3.7] at play.core.Router$Routes$TaggingInvoker.call(Router.scala:464) ~[play_ 2.11-2.3.7.jar:2.3.7] 在 Routes$$anonfun$routes$1$$anonfun$applyOrElse$1.apply(routes_routing.scala:72) ~[na:na] [error] 应用程序 - 呈现默认时出错错误页面 scala.MatchError: java.lang.NoClassDefFoundError: 无法初始化类控制器.Application$(类 java.lang.NoClassDefFoundError) at play.api.GlobalSettings$class.onError(GlobalSettings.scala:148) ~[play y_2.11-2.3.7.jar:2.3.7] at play.api.DefaultGlobal$.onError(GlobalSettings.scala: 206) [play_2.11- 2.3.7.jar:2.3.7] 在 play.core.server.Server$class.logExceptionAndGetResult$1(Server.scala:63) [play_2.11-2.3.7.jar:2.3. 7] 在 play.core.server.Server$$anonfun$getHandlerFor$4.apply(Server.scala:7 3) [play_2.11-2.3.7.jar:2.3.7] 在 play.core.server.Server$ $anonfun$getHandlerFor$4.apply(Server.scala:7 1) [play_2.11-2.3.7.jar:2.3.7]logExceptionAndGetResult$1(Server.scala:63) [play_2.11-2.3.7.jar:2.3.7] at play.core.server.Server$$anonfun$getHandlerFor$4.apply(Server.scala:7 3) [play_2 .11-2.3.7.jar:2.3.7] 在 play.core.server.Server$$anonfun$getHandlerFor$4.apply(Server.scala:7 1) [play_2.11-2.3.7.jar:2.3. 7]logExceptionAndGetResult$1(Server.scala:63) [play_2.11-2.3.7.jar:2.3.7] at play.core.server.Server$$anonfun$getHandlerFor$4.apply(Server.scala:7 3) [play_2 .11-2.3.7.jar:2.3.7] 在 play.core.server.Server$$anonfun$getHandlerFor$4.apply(Server.scala:7 1) [play_2.11-2.3.7.jar:2.3. 7]

0 投票
3 回答
2415 浏览

c# - Akka.net DI - 如何通过 DI 注入两个演员?

我想做的是将两个演员(妈妈演员和爸爸演员)传递给儿童演员。由于使用演员参考而不是演员是最佳实践,因此我使用 IActorRef 为木乃伊演员和爸爸演员通过 DI 注入命名参数。但我收到“mummyActor 不是唯一的”错误。知道如何解决吗?

0 投票
1 回答
333 浏览

akka.net - Akka.net routee 的父级

这可能是一个新手的问​​题,但我在这里和http://getakka.net/docs/上都找不到答案。所以,问题是 - 谁是 routee 演员的父母?实际路由器的主管还是路由器本身?

0 投票
1 回答
1774 浏览

akka - 具有远程节点的 Akka (.net) 集群:解除关联异常

使用 akka (.net) 我正在尝试实现简单的集群用例。

  1. 集群 - 用于节点启动/关闭事件。
  2. 远程 - 用于向特定节点发送消息。

有两个参与者:监听集群事件的主节点和连接到集群的从节点。

当 ClusterEvent.MemberUp 消息被接收到主节点创建参与者链接时:

向这个actor发送消息会导致错误:


与远程系统 akka.tcp://ClusterSystem@slave:8090 关联失败;地址现在门控 5000 ms。原因是:[解除关联]


主配置:

从配置: