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
Milestone

Comments

@georgeyanev
Copy link

@georgeyanev 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

This comment has been minimized.

Copy link
Member

@johanandren johanandren commented Nov 28, 2019

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 label Nov 28, 2019
@georgeyanev

This comment has been minimized.

Copy link
Author

@georgeyanev georgeyanev commented Nov 28, 2019

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

@johanandren

This comment has been minimized.

Copy link
Member

@johanandren johanandren commented Nov 28, 2019

Thanks for verifying, that sounds surprising indeed.

@johanandren johanandren self-assigned this Dec 16, 2019
johanandren added a commit to johanandren/akka that referenced this issue Dec 16, 2019
helena added a commit that referenced this issue Dec 18, 2019
@helena helena added this to the 2.6.2 milestone Dec 18, 2019
@helena helena closed this Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.