I used the following example to configure a communication listener for my Stateful Service
:
Relevant snippet:
public Task<string> OpenAsync(CancellationToken cancellationToken)
{
var serviceEndpoint = this.serviceContext.CodePackageActivationContext.GetEndpoint(this.endpointName);
var protocol = serviceEndpoint.Protocol;
int port = serviceEndpoint.Port;
if (this.serviceContext is StatefulServiceContext)
{
StatefulServiceContext statefulServiceContext = this.serviceContext as StatefulServiceContext;
this.listeningAddress = string.Format(
CultureInfo.InvariantCulture,
"{0}://+:{1}/{2}{3}/{4}/{5}",
protocol,
port,
string.IsNullOrWhiteSpace(this.appRoot)
? string.Empty
: this.appRoot.TrimEnd('/') + '/',
statefulServiceContext.PartitionId,
statefulServiceContext.ReplicaId,
Guid.NewGuid());
}
...
Service manifest snippet:
<Endpoints>
<Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" Port="8090" />
<Endpoint Name="ReplicatorEndpoint" />
</Endpoints>
Now when deploy my application, I get my service on URL with all kind of guids:
If I try to access http://localhost:8090/
on itself, I'm getting error 503
Any way to map the general URL to the Primary partition and replica? Or is it impossible in Stateful Services? In Stateless you will get this out of the box.