在过去的几周里,我一直在从云服务迁移到Service Fabric,并且使用两个服务之间的Remoting遇到了一些绊脚石.
我一直在使用Service Remoting上的官方文档和示例代码,特别是我试图让这里概述的示例工作:
我有2项服务.一个名为"RemoteService",另一个名为"CallerService".两者都源自默认的无状态服务项目.
在"RemoteService"和"CallerService"项目中,我添加了以下接口来描述它们之间的服务契约:
public interface IMyService : IService
{
Task<string> HelloNameAsync(string name);
}
Run Code Online (Sandbox Code Playgroud)
在"RemoteService"中,我在RemoteService类中创建了asociated方法
public Task<string> HelloNameAsync(string name)
{
return Task.FromResult("Hello " + name + "!");
}
Run Code Online (Sandbox Code Playgroud)
我还使用以下内容覆盖CreateServiceInstanceListeners
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new[] { new ServiceInstanceListener(context => this.CreateServiceRemotingListener(context)) };
}
Run Code Online (Sandbox Code Playgroud)
在我的"CallerService"中,当我尝试连接时,使用以下内容调用"RemoteService":
IMyService helloNameClient = ServiceProxy.Create<IMyService>(new Uri("fabric:/Application/RemoteService"));
string message = await helloNameClient.HelloNameAsync("Luke");
Run Code Online (Sandbox Code Playgroud)
我得到了这个例外
InnerException = {"Interface id '1994370306' is not implemented by …Run Code Online (Sandbox Code Playgroud) 是否可以在Service Fabric Cluster中将服务或参与者从一个应用程序调用到另一个应用程序?当我尝试(使用正确的Uri使用ActorProxy.Create)时,我得到了"没有为界面找到MethodDispatcher"