Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7884203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:44:09+00:00 2026-06-03T04:44:09+00:00

What is a good way of having an actor try something again on failure,

  • 0

What is a good way of having an actor try something again on failure, but with growing time intervals between the retries? Let’s say I want the actor to try again after 15 seconds, then 30 seconds, then every minute for a limited number of times.

Here’s what I’ve come up with:

  • the method of the actor that performs the actual work has an optional
    RetryInfo parameter that, if present, contains the number of the
    retry we are currently in
  • on failure, the actor will send itself a new ScheduleRetryMessage with retryCount + 1, then throw a RuntimeException
  • another actor supervises the worker actor, using new OneForOneStrategy(-1, Duration.Inf() returning Resume as its Directive. The actor has no state, so Resume should be OK
  • on receiving the ScheduleRetryMessage, the actor will
    • if retryCount < MAX_RETRIES: use Akka’s scheduler to schedule sending a RetryMessage after the desired delay
    • else: finally give up, sending a message to another actor for error reporting

Is this a good solution or is there a better approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:44:11+00:00Added an answer on June 3, 2026 at 4:44 am

    You could have a supervisor that starts the worker actor. The tip from the docs is to declare a router of size one for the worker. The supervisor would keep track of the number of retries, then schedule the message send to the worker as appropriate.

    Even though you would be creating another layer of actors, this seems cleaner to me since you would be keeping the supervisory functionality out of the worker. Ideally you could make this 1 supervisor to n workers, but I think you would have to use Lifecycle Monitoring to get a Failure from a child actor. In that case, you could just keep a map of [ActorRef, Int] to keep track of the number of retries for all supervised workers. The supervision policy would Resume, but if you reached your max retries, you could send a PoisonPill to the offending ActorRef.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, so I'm having a hard time coming up with a 'good' way to
I'm having a hard time coming up with a good way to number the
What is a good way of writing something like this in one line. The
I have been having some trouble finding a good way to output just the
I'm having trouble thinking up a good way to implement a file importing class,
I'm having problems coming up with a good way to validate user input. I'm
Hilariously, I'm having incredible difficulty finding any half-good way to determine whether or not
I'm having an issue coming up with a good way to do the following.
Is there a good way to see what format an image is, without having
This seems like such a simple task, but I'm having a hard time finding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.