Roman
Roman

Reputation: 66216

How to prevent repeated processing of failed message by ask pattern in Akka?

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)?

Upvotes: 1

Views: 96

Answers (1)

lutzh
lutzh

Reputation: 4965

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

Upvotes: 1

Related Questions