標準fabric:/AppName/ServiceName
の代わりにサービスが使用するURLを定義できますか?サービスファブリックはファブリックURLを指定します
これがアプリケーションレベルで設定可能かどうかはわかりません。
標準fabric:/AppName/ServiceName
の代わりにサービスが使用するURLを定義できますか?サービスファブリックはファブリックURLを指定します
これがアプリケーションレベルで設定可能かどうかはわかりません。
はい、あなたはサービスのクラス名から取った名前以外の何かにApplicationManifest.xml
にサービスの名前を変更することができます。
ショート:そのサービスのname
アトリビュートをApplicationManifest.xml
に変更するだけです。
:
ServiceRuntime.RegisterServiceAsync("JustAnotherStatelessServiceType",
context => new JustAnotherStatelessService(context)).GetAwaiter().GetResult();
そして、そのサービスのServiceManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest ...>
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="JustAnotherStatelessServiceType" />
</ServiceTypes>
...
中:このようProgram.cs
に登録 public interface IJustAnotherStatelessService : IService
{
Task<string> SayHelloAsync(string someValue);
}
internal sealed class JustAnotherStatelessService : StatelessService, IJustAnotherStatelessService
{
// Service implementation
}
:私は、このサービスを使用している場合これは先に行くと、アプリケーションマニフェストに名前を変更し、今
fabric:/app_name/JustAnotherStatelessService
のようなサービス、あなたにあなたのウリを与える
<ApplicationManifest ...>
<DefaultServices>
<Service Name="JustAnotherStatelessService">
<StatelessService ServiceTypeName="JustAnotherStatelessServiceType" InstanceCount="[JustAnotherStatelessService_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>
:
ApplicationManifest.xml
あなたが提案された名前を取得しますで
<ApplicationManifest ...>
<DefaultServices>
<Service Name="AwesomeService">
<StatelessService ServiceTypeName="JustAnotherStatelessServiceType" InstanceCount="[JustAnotherStatelessService_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>
そして、あなたのサービスになりました
への回答ここからこのURIビルダー(ServiceUriBuilder.cs)クラスを使用することができます。https://github.com/Azure-Samples/service-fabric-dotnet-web-reference-app/blob/master/ReferenceApp/Common/ServiceUriBuilder.cs
ステートレスサービスでは、あなたが簡単にプロキシを取得することができます。ステートフルサービスについては
var serviceUri = new ServiceUriBuilder(ServiceName);
var proxyFactory = new ServiceProxyFactory();
var svc = proxyFactory.CreateServiceProxy<IServiceName>(serviceUri.ToUri());
パーティションを指定する必要があります。
var serviceUri = new ServiceUriBuilder(StatefulServiceName);
var proxyFactory = new ServiceProxyFactory();
//this is just a sample of partition 1 if you are using number partitioning.
var partition = new ServicePartitionKey(1);
var svc = proxyFactory.CreateServiceProxy<IStatefulServiceName>(serviceUri.ToUri(), partition);
応答いただきありがとうございます、私は私の要件と明確ではなかったと思う。私はアプリケーションが 'fabric:/ foobarbazservice'を聞くことができるかどうかを知りたいと思っていましたが、サービスリゾルバがアプリケーションタイプ内でサービスタイプを探していて、 ! – Mardoxx
いいえ、その部分は正しいです、あなたはURLの{applicationName}/{serviceName_set_in_ApplicationManifest}体系に限られています。私は、ファブリックトランスポートがUrl internalyを構築する方法を考えれば、完全にカスタムURLを設定する方法はありません。 – yoape