public async Task <IActionResult> GetStatelessBackendRemotingV1() { string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/StatelessBackendRemotingV1"; var proxyFactory = new CorrelatingServiceProxyFactory(this.serviceContext, callbackClient => new FabricTransportServiceRemotingClientFactory(callbackClient: callbackClient)); IStatelessBackendService proxy = proxyFactory.CreateServiceProxy <IStatelessBackendService>(new Uri(serviceUri)); long result = await proxy.GetCountAsync(); ViewData["Message"] = result; return(View("~/Views/Home/Index.cshtml")); }
public static TServiceInterface Create <TServiceInterface>( Uri serviceUri, ServicePartitionKey partitionKey = null, TargetReplicaSelector targetReplicaSelector = TargetReplicaSelector.Default, string listenerName = null) where TServiceInterface : IService { var proxyFactory = new CorrelatingServiceProxyFactory(callbackClient => new FabricTransportServiceRemotingClientFactory(callbackClient: callbackClient)); TServiceInterface proxy = proxyFactory.CreateServiceProxy <TServiceInterface>(serviceUri, partitionKey, targetReplicaSelector, listenerName); return(proxy); }
public static T CreateServiceProxyWithCorrelation <T>(string serviceAddress) where T : IService { var sfrRetryInterval = TimeSpan.Parse(ConfigurationManager.AppSettings.GetRefValue <string>("ServiceFabricRemoting_OperationRetryInterval")); var sfrRetryCount = int.Parse(ConfigurationManager.AppSettings.GetRefValue <string>("ServiceFabricRemoting_OperationRetryCount")); var sfrTimeout = TimeSpan.Parse(ConfigurationManager.AppSettings.GetRefValue <string>("ServiceFabricRemoting_OperationTimeout")); var fabricTransportRemotingSettings = new FabricTransportRemotingSettings { OperationTimeout = sfrTimeout }; var operationRetrySettings = new OperationRetrySettings(sfrRetryInterval, sfrRetryInterval, sfrRetryCount); // read https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-communication-remoting // _dependencyClient = ServiceProxy.Create<IDependency>(new Uri(serviceAddress)); var proxyFactory = new CorrelatingServiceProxyFactory( callbackClient => new FabricTransportServiceRemotingClientFactory( callbackClient: callbackClient, FabricTransportRemotingSettings: fabricTransportRemotingSettings), retrySettings: operationRetrySettings); return(proxyFactory.CreateServiceProxy <T>(new Uri(serviceAddress))); }