Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReceiveTimeout not triggered after actor restart #28266

Closed
georgeyanev opened this issue Nov 28, 2019 · 3 comments
Closed

ReceiveTimeout not triggered after actor restart #28266

georgeyanev opened this issue Nov 28, 2019 · 3 comments
Assignees
Labels
3 - in progress Someone is working on this ticket bug t:core
Milestone

Comments

@georgeyanev
Copy link

georgeyanev commented Nov 28, 2019

If the parent actor's strategy is 'restart' then the following snippet does not work as expected.
The ReceiveTimeout message is triggered only on first actor creation, but not after actor restarts

  @Override
  public void preStart() {
    getContext().setReceiveTimeout(Duration.create(10, TimeUnit.SECONDS));
  }

  @Override
  public Receive createReceive() {
    return receiveBuilder()
        .match(ReceiveTimeout.class, m -> processMessage())
        .build();
  }

  private void processMessage() {
    getContext().setReceiveTimeout(Duration.Undefined()); // turn off timer
    throw new RuntimeException("Test exception");
  }

This is tested on latest akka 2.5 and akka 2.6

@johanandren
Copy link
Member

Do you have an override of postRestart() in that actor? If so, if it doesn't call super.postRestart() it needs to call preStart() or else a restarted actor will never execute preStart() which would explain no receive timeout being set.

@johanandren johanandren added the 0 - new Ticket is unclear on it's purpose or if it is valid or not label Nov 28, 2019
@georgeyanev
Copy link
Author

@johanandren thanks for your response! Actually the preStart method is called after restart but the ReceiveTimeout message is not received.

@johanandren
Copy link
Member

Thanks for verifying, that sounds surprising indeed.

@johanandren johanandren added 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted bug t:core and removed 0 - new Ticket is unclear on it's purpose or if it is valid or not labels Nov 28, 2019
@johanandren johanandren self-assigned this Dec 16, 2019
@johanandren johanandren added 3 - in progress Someone is working on this ticket and removed 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted labels Dec 16, 2019
johanandren added a commit to johanandren/akka that referenced this issue Dec 16, 2019
@helena helena added this to the 2.6.2 milestone Dec 18, 2019
@helena helena closed this as completed Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - in progress Someone is working on this ticket bug t:core
Projects
None yet
Development

No branches or pull requests

3 participants