3

I have this Play app that connects to a distant server in order to consume a given 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. Each account is handled by an Akka actor and these actors are behind an Akka Round Robin router. Thus when wanting to consume the distant API, I "ask" the RR router for the wanted info.

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.

My question is, instead of having to have the "retry" logic outside the router-routee group, is there a way to do it inside? 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?

Peter
  • 7,020
  • 4
  • 31
  • 51

1 Answers1

0

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.

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.

hicolour
  • 784
  • 5
  • 11