Would you please point to an example or clarify how to implement HttpCommunicationListener class in bullet point No.8 where a stateful service is being setup?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
In fact it's not clear how ProcessInternalRequest is invoked within the implementation of HttpCommunicationListener class presumably within OpenAsync method.
Thanks for the feedback! We are currently investigating and will update you shortly.
@Arash-Sabet you can find an example of how to implement the HttpCommunicationListener class in this doc
class HttpCommunicationListener : ICommunicationListener
{
...
public Task<string> OpenAsync(CancellationToken cancellationToken)
{
EndpointResourceDescription endpoint =
serviceContext.CodePackageActivationContext.GetEndpoint("WebEndpoint");
string uriPrefix = $"{endpoint.Protocol}://+:{endpoint.Port}/myapp/";
this.httpListener = new HttpListener();
this.httpListener.Prefixes.Add(uriPrefix);
this.httpListener.Start();
string publishUri = uriPrefix.Replace("+", FabricRuntime.GetNodeContext().IPAddressOrFQDN);
return Task.FromResult(publishUri);
}
...
}
class WebService : StatelessService
{
...
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new[] { new ServiceInstanceListener(context => new HttpCommunicationListener(context))};
}
...
}
Thanks @MicahMcKittrick-MSFT.
Yes, I ran into that sample already. There are two things though which are not clear:
How ProcessInputRequest is invoked within OpenAsync ? If not invoked, then what's the point of including it in the scope?
Publish Uri, and Uri prefix are already computed in the following method in this document. Why OpenAsync is repeating the same logic?
private ICommunicationListener CreateInternalListener(ServiceContext context)
{
EndpointResourceDescription internalEndpoint = context.CodePackageActivationContext.GetEndpoint("ProcessingServiceEndpoint");
string uriPrefix = String.Format(
"{0}://+:{1}/{2}/{3}-{4}/",
internalEndpoint.Protocol,
internalEndpoint.Port,
context.PartitionId,
context.ReplicaOrInstanceId,
Guid.NewGuid());
string nodeIP = FabricRuntime.GetNodeContext().IPAddressOrFQDN;
string uriPublished = uriPrefix.Replace("+", nodeIP);
return new HttpCommunicationListener(uriPrefix, uriPublished, this.ProcessInternalRequest);
}
Quite frankly, this document requires the reader to go back and forth a lot causing to lose the logical flow of this tutorial. Such gray areas should be mitigated.
@Arash-Sabet thanks for clarifying.
I will assign to the author to comment further and review the doc to see where we can make it more clear
This sample code section is really unclear and not maintained. It is very easy to share through GitHub, why not?
It can be very help to share the project in GitHub and explain more about HttpCommunicationListener. How ProcessInternalRequest is executed. @MicahMcKittrick-MSFT any update from the author as you suggested ealier
What a crap!
Most helpful comment
Thanks @MicahMcKittrick-MSFT.
Yes, I ran into that sample already. There are two things though which are not clear:
How
ProcessInputRequestis invoked withinOpenAsync? If not invoked, then what's the point of including it in the scope?Publish Uri, and Uri prefix are already computed in the following method in this document. Why
OpenAsyncis repeating the same logic?Quite frankly, this document requires the reader to go back and forth a lot causing to lose the logical flow of this tutorial. Such gray areas should be mitigated.