0
votes

I have a Stateless service on Service Fabric (ASP.NET Core) which will call an Actor and the Actor may internally also call other Actors and/or Stateful Services depending on the scenarios.

My question is, do we need to account for duplicate requests due to the remoting aspect of the system?

In our earlier Akka.Net implementations there was a chance that the Actor received duplicate requests due to TCP/IP network congestion etc, and we handled that by giving each message a unique Correlation Id. We would store the request and its outcome in state on the actors and if the same correlation id came back again, we would just assume it was a duplicate and sent the earlier outcome instead of re-processing the request.

I had seen a similar approach used in one of the sample projects Microsoft had but I can't seem to find that anymore (dead link on Github).

Does anyone know if this needs to be handled in Actor and or Stateful services?

1

1 Answers

0
votes

You could add custom headers in your remoting calls, by creating a custom implementations of IServiceRemotingClientFactory and IServiceRemotingClient.

Add custom headers inside the operations RequestResponseAsync and SendOneWay.

Another example by Peter Bons here.:

var header = requestRequestMessage.GetHeader();
var customHeaders = customHeadersProvider.Invoke() ?? new CustomHeaders();
header.AddHeader(CustomHeaders.CustomHeader, customHeaders.Serialize());

On the receiving side, you can get the custom header from IServiceRemotingRequestMessageHeader in a custom ActorServiceRemotingDispatcher.