1

Original description is updated after some investigation:

When I send a message to an actor via the Ask pattern, and the actor fails with an exception, the message is processed again.

The exact number of retries varies, and I was not able to understand the principle. In most of my experiments, a failing message is retried 3 times.

How can I fine-tune the Ask-pattern behavior (e.g. set a predictable number of retries)?

Roman
  • 64,384
  • 92
  • 238
  • 332
  • How about adding a number of attempts to the message itself? When the message comes in, create a clone with incremented counter. Then you can check whether the number of attempts exceeds the limit and drop the message within an actor itself? `case RetryMessage(payload, counter) if counter > limit => // drop it` – kukido Mar 25 '16 at 19:32

1 Answers1

1

You questions is somewhat confusing to me as I think what you describe as the default is not the default. A failed message is not processed 3 times by default. By default, if an exception occurs in an Actor, it is restarted and continues with the next message. See http://doc.akka.io/docs/akka/current/scala/fault-tolerance.html#Default_Supervisor_Strategy

So to your questions:

How can I implement the logic which will restart my actor, but will skip failed message and will not try to process it again and again?

That's the default.

How is the default supervisor on guardian actor implemented? If someone has an idea how to find this place in their Github, it would be quite helpful.

https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/akka/actor/FaultHandling.scala#L154

lutzh
  • 4,917
  • 1
  • 18
  • 21
  • I did some investigation and it turned out that using ask-pattern caused all those retries. I updated the description – Roman Mar 28 '16 at 18:21