Reputation: 1237
I have a question about Akka Timeouts.
For example, I have the Supervisor actor which sends a message to DBActor to start reading the database. The Supervisor sets a timeout of 5 seconds.
The DBActor starts reading the database; it gets the ResultSet, and then enters a loop to iterate the ResultSet rows and build the return value.
Then the Supervisor experiences a Timeout exception and returns a value from the .recover block
My question is ; does the DBActor continue to loop through the ResultSet after the TimeoutException ? Because that would be a resource leak.
Upvotes: 0
Views: 54
Reputation: 27356
The DBActor is independent of the supervisor and will keep processing the records until it is finished or is told to stop. It does not matter that the supervisor has given up on the current request because the DBActor does not know this. If you want the process to stop early, the supervisor will have to send another message to the DBActor to tell it to abort the operation. The supervisor will also have to deal with the case where the results arrive after the timeout has expired.
Also note that Scala cannot "leak" resources as such because it implements garbage collection. If resources are accumulating somewhere it is because a reference to that resource is being held by an object.
Upvotes: 1