I want to be able to call a stateful HTTP/WebApi service from a non-fabric app or service. I could just use the published urls for the stateful service but want to take advantage of failover to a different primary by resolving the partition endpoints.
I tried first to test in a desktop console app but it fails to execute the communications Lambda function inside of InvokeWithRetryAsync.
Is this a dead end (non fabric apps can't resolve stateful services) or is there another way to resolve the endpoint from non-fabric apps. Otherwise, I will likely wrap the requests in a "middleman" stateless service (like Wordcount Webservice).
var result = await servicePartitionClient.InvokeWithRetryAsync(
client =>
{
//never reaches here.
Uri serviceAddress = new Uri(client.BaseAddress, "SetConfiguration");
HttpWebRequest request = WebRequest.CreateHttp(serviceAddress);
request.Method = "POST";
//Add the content into the body
byte[] byteArray = Encoding.UTF8.GetBytes(_datapacket);
request.ContentType = "application/json";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
request.Timeout = (int)client.OperationTimeout.TotalMilliseconds;
request.ReadWriteTimeout = (int)client.ReadWriteTimeout.TotalMilliseconds;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//for now, just return ok
return Task.FromResult<string>("ok");
});