Skip to content

Commit

Permalink
Close connections when shutting down the the cluster (which will trig…
Browse files Browse the repository at this point in the history
…ger sending a close announcement)

Signed-off-by: Florian Fendt <Florian.Fendt@bosch.io>
  • Loading branch information
ffendt committed May 7, 2021
1 parent f3cbc12 commit d80c088
Showing 1 changed file with 12 additions and 0 deletions.
Expand Up @@ -131,6 +131,7 @@
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.ActorSystem;
import akka.actor.CoordinatedShutdown;
import akka.actor.FSM;
import akka.actor.OneForOneStrategy;
import akka.actor.Props;
Expand Down Expand Up @@ -318,6 +319,17 @@ public void preStart() throws Exception {
clientActorRefsNotificationDelay);
}
clientActorRefs.add(getSelf());

closeConnectionBeforeTerminatingCluster();
}

private void closeConnectionBeforeTerminatingCluster() {
CoordinatedShutdown.get(getContext().getSystem())
.addActorTerminationTask(
CoordinatedShutdown.PhaseBeforeServiceUnbind(),
"closeConnection",
getSelf(),
Optional.of(CloseConnection.of(connectionId(), DittoHeaders.empty())));
}

@Override
Expand Down

0 comments on commit d80c088

Please sign in to comment.