Skip to content

Commit

Permalink
Call BoundaryEvent cancellation hook for telemetry when ActorGraphInt…
Browse files Browse the repository at this point in the history
…erpreter stops (#30259)

* Call BoundaryEvent cancellation hook for telemetry when ActorGraphInterpreter stops
* Add missing annotation to ActorCell.sendMessage
  • Loading branch information
ygree committed May 27, 2021
1 parent 3ae85e8 commit cbb12e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions akka-actor/src/main/scala/akka/actor/ActorCell.scala
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ private[akka] trait Cell {
* schedule the actor to run, depending on which type of cell it is.
* Is only allowed to throw Fatal Throwables.
*/
@InternalStableApi
final def sendMessage(message: Any, sender: ActorRef): Unit =
sendMessage(Envelope(message, sender, system))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -829,12 +829,23 @@ import akka.util.OptionVal
newShells.map(shell => shell.toSnapshot.asInstanceOf[UninitializedInterpreter]))
}

override def postStop(): Unit =
override def postStop(): Unit = {
if (shortCircuitBuffer ne null) {
while (!shortCircuitBuffer.isEmpty) {
shortCircuitBuffer.poll() match {
case b: BoundaryEvent =>
// signal to telemetry that this event won't be processed
b.cancel()
case _ => // ignore
}
}
}
// avoid creating exception in happy case since it uses self.toString which is somewhat slow
if (activeInterpreters.nonEmpty || newShells.nonEmpty) {
val ex = AbruptTerminationException(self)
activeInterpreters.foreach(_.tryAbort(ex))
activeInterpreters = Set.empty[GraphInterpreterShell]
newShells.foreach(s => if (tryInit(s)) s.tryAbort(ex))
}
}
}

0 comments on commit cbb12e6

Please sign in to comment.