I am running a local 5 node service fabric cluster.
In order to have finer control over long running actors, I want to delete the actors when required.
Referring to the documentation for deleting actors and enumerating actors I came up with the following code
//create actor ID, get instance and call a method on the actor
ActorId id = ActorId.CreateRandom();
IActor1 myActor = ActorProxy.Create<IActor1>(id, new Uri(URI));
Console.WriteLine(myActor.GetCountAsync().GetAwaiter().GetResult() + "ActorID:" + id.GetPartitionKey());
IActorService myActorServiceProxy = ActorServiceProxy.Create(new Uri(URI), id);
//delete actor from Actor service
myActorServiceProxy.DeleteActorAsync(id, new CancellationToken()).GetAwaiter().GetResult();
//enumerate actors
IActorService actorServiceProxy = ActorServiceProxy.Create(new Uri(URI), id.GetPartitionKey());
ContinuationToken continuationToken = null;
List<ActorInformation> activeActors = new List<ActorInformation>();
do
{
PagedResult<ActorInformation> page = actorServiceProxy
.GetActorsAsync(continuationToken, new CancellationToken()).GetAwaiter().GetResult();
activeActors.AddRange(page.Items.Where(x => x.IsActive));
continuationToken = page.ContinuationToken;
}
while (continuationToken != null);
foreach(ActorInformation info in activeActors)
{
Console.WriteLine("INFO:" + info.ActorId + ":" + info.IsActive);
}
//call the method again
Console.WriteLine(myActor.GetCountAsync().GetAwaiter().GetResult() + "ActorID:" + id.GetLongId());
And the output that I get is0ActorID:1952475710829467062
0ActorID:1952475710829467062
where 0 is the return value of the method.
I understand that the actor has been deleted from the service as nothing was printed in the foreach loop, but how did my second call to the actor method succeed if the actor was deleted? Was it recreated? Please do help me out in understanding that.