1

I have deployed two Stateless and SinglePartion Microservices into a Service Fabric cluster, which are hosted on Azure. Now I want to hook up the communication between these services like this:enter image description here

My Masterdata Web API Service should prefer to communicate with a Masterdata ServiceProxy Service replica/instance on the same node when calling a method via the ServiceProxy client. If there's no replica/instance available on the same node, connect to another node. The code looks like this:

var serviceClient = ServiceProxy.Create<IMasterDataServiceProxy>(new Uri("fabric:/sfApp/MasterDataServiceProxy"));
var result = await serviceClient.GetMasterData();

But actually the communication is like this:

enter image description here

The ServiceProxy connects to a randomly chosen replica/instance (due to TargetReplicaSelector.Default). I'm missing some communication options like "TargetReplicaSelector.PreferSameNode". Is there any way to handle this manually?

MegaMax
  • 151
  • 1
  • 8

2 Answers2

4

Here's a good explanation: How can I reach a specific replica of a stateless service

If you still really want it, either

  • use http listeners on localhost or
  • use a stateful service (using StateManager is optional)
Community
  • 1
  • 1
LoekD
  • 11,402
  • 17
  • 27
3

Not with Service Remoting (ServiceProxy), but with HTTP sure! Just grab the current node IP and make a request to your other service URL.

Of course, that does mean your Masterdata ServiceProxy Service would have to change to a Masterdata Web API Service.

Vaclav Turecek
  • 9,020
  • 24
  • 29