简体   繁体   English

将消息转发给下一轮Round Robin routee

[英]Forward message to next Round Robin routee

I have this Play app that connects to a distant server in order to consume a given API. 我有这个连接到远程服务器的Play应用程序,以便使用给定的API。 In order to load balance my requests to the distant server, I connect multiple accounts to that same server. 为了将我的请求负载平衡到远程服务器,我将多个帐户连接到同一台服务器。 Each account can query the API a given number of times. 每个帐户都可以查询API给定次数。 Each account is handled by an Akka actor and these actors are behind an Akka Round Robin router. 每个帐户都由Akka演员处理,这些演员都在Akka Round Robin路由器后面。 Thus when wanting to consume the distant API, I "ask" the RR router for the wanted info. 因此,当想要使用远程API时,我向RR路由器“询问”所需信息。

This implementation runs fine until, one account gets disconnected. 此实现运行正常,直到一个帐户断开连接。 Basically, when one account is disconnected, the actor returns a given object that says "something was wrong with the connection", and then I send a second request to the RR router again to be handled by another account. 基本上,当一个帐户断开连接时,actor返回一个给定的对象,说“连接有问题”,然后我再次向RR路由器发送第二个请求,由另一个帐户处理。

My question is, instead of having to have the "retry" logic outside the router-routee group, is there a way to do it inside? 我的问题是,不是必须在router-routee组之外拥有“重试”逻辑,有没有办法在里面做? I am thinking that for example at router level, define a logic that handles these "something was wrong with the connection" messages by automatically forwarding the request to the next routee to be handled by it, and only return a final response once all routees have been tried and none worked? 我在想,例如在路由器级别,定义一个逻辑,通过自动将请求转发给下一个由它处理的路由器来处理这些“连接错误”消息,并且只有在所有路由都有时才返回最终响应已经尝试过没有用过?

Does Akka provide a simple way of achieving this or should I just carry on with my implementation? Akka是否提供了实现这一目标的简单方法,还是应该继续实施?

I'm not sure if I fully understand your design but I think you should try using first complete model supported by the ScatterGatherFirstCompleted routing logic. 我不确定我是否完全理解您的设计,但我认为您应该尝试使用ScatterGatherFirstCompleted路由逻辑支持的第一个完整模型

router.type-mapping {
  ...
  scatter-gather-pool = "akka.routing.ScatterGatherFirstCompletedPool"
  scatter-gather-group = "akka.routing.ScatterGatherFirstCompletedGroup"
  ..
}

in the simple form 以简单的形式

                  ---> Route
       --> SGFC-1 
RR ->  

or possibly combined with round robin router. 或者可能与循环路由器结合使用。

                  ---> Route
       --> SGFC-1 
RR ->
       --> SGFC-2
                  ---> Route

The same as in your proposal connections are represented by the routes. 与您的提案中的连接相同,路由表示连接。 SGFC-1 and SGFC-2 should have access to the same pool of routees (conenctions.) or part of the pool. SGFC-1和SGFC-2应该可以访问相同的路由池(conenctions。)或池的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM