Since we migrated to play framework 2.5 (akka version 2.4.4; scala version: 
2.11) we have a weird behavior when calling PatternsCS.ask in one of our 
services.

This service is responsible for collecting several data from other 
different services, so we have lots of actors being created to collect it.
The process starts running normally but sometimes (I couldn't find any 
pattern behavior) the temporary actor, created by the ask call, is 
terminated before delivering the message to the caller.

I added some logs in the code to better understand what's going on, so a 
normal log is like this:

[info] [2016-05-13 08:10:40,232] 
[application-akka.actor.broker-dispatcher-32] 
[afroms.broker.models.service.BrokerInvoker] - BROKER_INVOKER START_MSG: 1; 
caller: Actor[akka://application/temp/$a]
[info] [2016-05-13 08:10:40,416] 
[application-akka.actor.broker-dispatcher-21] 
[afroms.broker.models.service.ServiceInvoker] - ServiceInvoker 1; sending 
response message to: Actor[akka://application/temp/$a]
[info] [2016-05-13 08:10:40,416] [ForkJoinPool.commonPool-worker-1] 
[afroms.broker.models.payload.InternalServicePayload] - 
InternalServicePayload_Response 1
[info] [2016-05-13 08:10:40,429] 
[application-akka.actor.broker-dispatcher-35] 
[afroms.broker.models.service.BrokerInvoker] - BROKER_INVOKER 
TERMINATED_MSG: Terminated(Actor[akka://application/temp/$a])

The first line is when the supervisor actor receives a message from the 
caller which is the actor created by PatternsCS.ask, then the supervisor 
creates a child actor and sends the message to it.
Second line, is when the child actor finish the work and sends the response 
to the original caller (the temporary actor).
Third line, is when the response arrives to the caller (the temporary 
actor).
Fourth line, is when the temporary actor terminate.

After sometime running, happens something like this:

[info] [2016-05-13 08:11:44,478] 
[application-akka.actor.broker-dispatcher-38] 
[afroms.broker.models.service.BrokerInvoker] - BROKER_INVOKER START_MSG: 
35134; caller: Actor[akka://application/temp/$9Ki]
[info] [2016-05-13 08:11:44,486] 
[application-akka.actor.broker-dispatcher-38] 
[afroms.broker.models.service.ServiceInvoker] - ServiceInvoker 35134; 
sending response message to: Actor[akka://application/temp/$9Ki]
[info] [2016-05-13 08:11:44,486] 
[application-akka.actor.broker-dispatcher-56] 
[afroms.broker.models.service.BrokerInvoker] - BROKER_INVOKER 
TERMINATED_MSG: Terminated(Actor[akka://application/temp/$9Ki])

*The temporary actor terminates before delivering the message to the 
process who called him.*

These are the snapshots of our code:

1º PatternsCS.ask call
  PatternsCS.ask(this.invoker, this, new Timeout(4, TimeUnit.MINUTES))
                  .thenApplyAsync(response -> {
                      logger.info("InternalServicePayload_Response " + 
currentCall);


                      return (ServicePayload) response;
                  });


2º Supervisor receives the message, creates the child actor and sends the 
message to it. I also added a watch to the temporary actor to be notified 
when it terminates.
  ActorRef serviceInvoker = this.getContext().actorOf(ServiceInvoker.
getProps(this.injector), "ServiceInvoker" + currentServicePayloadCall);
  context().watch(sender);
  logger.info(String.format("BROKER_INVOKER START_MSG: %d; caller: %s", 
currentServicePayloadCall, sender.toString()));
  serviceInvoker.tell(msg, sender);


3º Child actor do the work and sends the result back to the temporary actor:
  logger.info("ServiceInvoker " + currentCounter + "; sending response 
message to: " + sender.toString());
  sender.tell(response, self);


*As far as we can tell no exception happens and this is a random behavior.*

I looked at the akka code trying to figure out what was the problem, and 
perhaps its related with the code inside object 
akka.pattern.PromiseActorRef:
  result.future onComplete { _ ⇒ try a.stop() finally f.cancel() }

What I understand from it, is that when the future returns we tell the 
actor to stop/finalize.

The same future is returned to the caller in here 
akka.pattern.AskSupport#ask:
  actorRef.internalAsk(message, timeout, ActorRef.noSender)

On my java code I expect also the future result:
PatternsCS.ask(this.invoker, this, new Timeout(4, TimeUnit.MINUTES))
                .thenApplyAsync(response -> {
                    logger.info("InternalServicePayload_Response " + 
currentCall);


                    return (ServicePayload) response;
                });


Can some one please help us figuring out what the problem is? If it's with 
our code or a akka code problem (remember that this was working previously 
on play 2.4 version; akka 2.3.14 version).

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to