all Technical posts

Serialization Error While Deleting Reliable Actors and Their State

During a Service Fabric implementation, where we tried to manually to garbage collect an Actor, we ran into some serialization issues. Let's have a look at how we solved this.

In Service Fabric when an Actor is deactivated, the actor object itself is being cleaned up. The state stored in the actor’s State Manager is not being removed in case of actor garbage collection. This is due to the fact that an actor is reactivated its data is again made available through the State Manager.

In our use case some of these actors are never being reactivated and therefore it is necessary to do a ‘manual’ clean up of their data.

Deleting the Actor

To delete our Reliable Actor and his associated stated we used the code sample provided on docs.microsoft.com and used the function provided by the Actor Service to delete the actors from a remote caller.

When using the above code sample we ran into serialization errors.

Element ‘http://schemas.microsoft.com/2003/10/Serialization/:anyType’ contains data from a type that maps to the name ‘urn:ServiceFabric.Communication:ServiceResponseMessageHeaders’. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver if you are using DataContractSerializer or add the type corresponding to ‘ServiceResponseMessageHeaders’ to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to the serializer

After some investigation we came to the conclusion that this issue was related to the incompatibility of V1 and V2 remoting in Service Fabric. The IActorService Proxy we assigned with the sample code of docs.microsoft.com was providing us with a V1 remoting endpoint.

To solve this, and to use the correct V2 remoting endpoint, we used the implementation below.

Hope you find it helpful, someday!

Cheers,

Glenn

Subscribe to our RSS feed

Hi there,
how can we help?

Got a project in mind?

Connect with us

Let's talk

Let's talk

Thanks, we'll be in touch soon!

Call us

Thanks, we've sent the link to your inbox

Invalid email address

Submit

Your download should start shortly!

Stay in Touch - Subscribe to Our Newsletter

Keep up to date with industry trends, events and the latest customer stories

Invalid email address

Submit

Great you’re on the list!