2017-02-09 4 views

答えて

0

はい、あなたはサービスのクラス名から取った名前以外の何かに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> 

そして、あなたのサービスになりました

への回答
+0

応答いただきありがとうございます、私は私の要件と明確ではなかったと思う。私はアプリケーションが 'fabric:/ foobarbazservice'を聞くことができるかどうかを知りたいと思っていましたが、サービスリゾルバがアプリケーションタイプ内でサービスタイプを探していて、 ! – Mardoxx

+1

いいえ、その部分は正しいです、あなたはURLの{applicationName}/{serviceName_set_in_ApplicationManifest}体系に限られています。私は、ファブリックトランスポートがUrl internalyを構築する方法を考えれば、完全にカスタムURLを設定する方法はありません。 – yoape

0

ここからこの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); 
関連する問題