public async Task <IActionResult> Index() { string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/" + this.configSettings.StatelessBackendServiceName; IStatelessBackendService proxy = ServiceProxy.Create <IStatelessBackendService>(new Uri(serviceUri)); ServiceEventSource.Current.ServiceMessage(this.serviceContext, "In the web service about to call the backend!"); long result = 0; int timeout = 10000; var task = proxy.GetCountAsync(); if (await Task.WhenAny(task, Task.Delay(timeout)) == task) { result = task.GetAwaiter().GetResult(); } else { throw new TimeoutException("This is taking unusually long. Something is wrong"); } ViewBag.Number = result; return(View()); }
public async Task <IActionResult> GetAsync() { string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/" + this.configSettings.StatelessBackendServiceName; IStatelessBackendService proxy = this.serviceProxyFactory.CreateServiceProxy <IStatelessBackendService>(new Uri(serviceUri)); ServiceEventSource.Current.ServiceMessage(this.serviceContext, "In the web service about to call the backend!"); long result = 0; int timeout = 10000; var task = proxy.GetCountAsync(); if (await Task.WhenAny(task, Task.Delay(timeout)) == task) { result = task.GetAwaiter().GetResult(); } else { throw new TimeoutException("This is taking unusually long. Something is wrong"); } // long result = await proxy.GetCountAsync().ConfigureAwait(false); // // if (result % 5 == 0) // { // throw new InvalidOperationException("Not happy with this number!"); // } // return(this.Json(new CountViewModel() { Count = result })); }
public async Task <IActionResult> GetStatelessBackend() { string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/StatelessBackend"; IStatelessBackendService proxy = ServiceProxy.Create <IStatelessBackendService>(new Uri(serviceUri)); long result = await proxy.GetCountAsync(); ViewData["Message"] = result; return(View("~/Views/Home/Index.cshtml")); }
public async Task <IActionResult> GetAsync() { string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/" + this.configSettings.StatelessBackendServiceName; IStatelessBackendService proxy = ServiceProxy.Create <IStatelessBackendService>(new Uri(serviceUri)); long result = await proxy.GetCountAsync(); return(this.Json(new { Count = result, Time = DateTime.Now })); }
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 async Task <IActionResult> GetAsync() { string serviceUri = serviceContext.CodePackageActivationContext.ApplicationName + "/" + configSettings.StatelessBackendServiceName; IStatelessBackendService proxy = ServiceProxy.Create <IStatelessBackendService>(new Uri(serviceUri)); long result = await proxy.GetCountAsync(); return(Json(new CountViewModel() { Count = result })); }
public async Task <IActionResult> GetAsync() { string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/" + this.configSettings.StatelessBackendServiceName; IStatelessBackendService proxy = ServiceProxy.Create <IStatelessBackendService>(new Uri(serviceUri)); ServiceEventSource.Current.ServiceMessage(this.serviceContext, "In the web service about to call the backend!"); long result = await proxy.GetCountAsync().ConfigureAwait(false); return(this.Json(new CountViewModel() { Count = result })); }
public async Task <IActionResult> GetAsync() { string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/" + this.configSettings.StatelessBackendServiceName; IStatelessBackendService proxy = ServiceProxy.Create <IStatelessBackendService>(new Uri(serviceUri)); ServiceEventSource.Current.ServiceMessage(this.serviceContext, "In the web service about to call the backend!"); return(await Activities.ServiceRemotingDependencyCallAsync(async() => { // Extract the request id and correlation context headers so they can be passed to the callee, which // will create the correlation Activity currentActivity = Activity.Current; string requestId = currentActivity.Id; long result = await proxy.GetCountAsync(requestId, currentActivity.Baggage).ConfigureAwait(false); return this.Json(new CountViewModel() { Count = result }); }, dependencyType : "StatelessServiceFabricService", dependencyName : "StatelessBackendService", target : serviceUri)); }