0

私はこれを動作させることができません、私はグーグルで、おそらくこれを行う方法に関するすべてのページを見つけました。サービスファブリック、V2からステートフルサービスへのRemotingが動作しない

基本的には、ステートレス.NETコア2 MVCアプリケーションからStatefullサービスにSF Remoting V2を取り入れるだけです。コントローラーで

クライアントコードを:(可能な限り簡素化された):ここでは

は、私がやっていることだ

public class ValuesController : Controller 
{ 

    [HttpGet] 
    public async Task<IEnumerable<string>> Get() 
    { 

     // Provide certificate details. 
     var serviceProxyFactory = new ServiceProxyFactory((c) => new FabricTransportServiceRemotingClientFactory()); 

     var proxy = serviceProxyFactory.CreateServiceProxy<ICallMe>(new Uri("fabric:/SFExperiment/Stateful1")); 

     var value3 = await proxy.GetGreeeting("Bob"); 

     return new[] { "value1", "value2", value3 }; 
    } 

サービスコードインタフェース:

using System.Threading.Tasks; 
using Microsoft.ServiceFabric.Services.Remoting; 
using Microsoft.ServiceFabric.Services.Remoting.FabricTransport; 


[assembly: FabricTransportServiceRemotingProvider(RemotingListener = 
RemotingListener.V2Listener, RemotingClient = RemotingClient.V2Client)] 

namespace Stateful1.Abstractions 
{ 

public interface ICallMe : IService 
{ 
    Task<string> GetGreeeting(string name); 
} 
} 

サービスコード:

Public sealed class Stateful1 : StatefulService, ICallMe 
{ 
    public Stateful1(StatefulServiceContext context) 
     : base(context) 
    { } 

    protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners() 
    { 
     return this.CreateServiceRemotingReplicaListeners(); 
    } 

    public Task<string> GetGreeeting(string name) 
    { 
     return Task.FromResult(@"Congratulations, you have remoting working. :-) "); 
    } 

..私は次の例外を取得し、私は

<Resources> 
<Endpoints> 
    <!-- To enable Service remonting for remoting services V2--> 
    <Endpoint Name="ServiceEndpointV2" /> 

    <Endpoint Name="ReplicatorEndpoint" /> 
</Endpoints> 
</Resources> 

ServiceManifest.xml

に下に追加して、それが動作しません。

無効なパーティション・キー/ ID '{0}' セレクタ{1}

私は間違っていますか?

答えて

1

サービスプロキシを作成する呼び出しでは、ステートフルサービスに接続しているため、パーティションキーを指定する必要があります。

long partitionKey = 0L; //TODO: Determine partition key 
var proxy = serviceProxyFactory.CreateServiceProxy<ICallMe>(new Uri("fabric:/SFExperiment/Stateful1"), new ServicePartitionKey(partitionKey), TargetReplicaSelector.PrimaryReplica); 

また、代わりに新しいものを作成するのではなく、あなたのサービスプロキシ工場を再利用することを確認してください。 たとえば、thisコードを見てください。

+0

うん、それだった...ありがとう。 – Choco

関連する問題