【问题标题】:How to add listeners to Actor Application?如何向 Actor 应用程序添加侦听器?
【发布时间】:2017-04-28 13:56:16
【问题描述】:

我正在使用以下代码在参与者中调用无状态服务:

为了解决这个问题,我们必须添加监听器,The primary or stateless instance for the partition has invalid address

但是这个方法 (CreateServiceReplicaListeners) 无法从 Actor 覆盖以注册远程。

当我们想从actor远程调用服务时,必须怎么做?

【问题讨论】:

  • 你能写一个服务之间通信的例子吗?目前尚不清楚谁打电话给谁。
  • @cassandrad : 更新问题,请看。

标签: azure azure-service-fabric


【解决方案1】:

1.将此添加到您的无状态服务代码,喜欢描述 here:

protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
    return new[] { new ServiceInstanceListener(context => 
        this.CreateServiceRemotingListener(context)) };
}

2.在你的Actor中,像这样调用服务:

var carUpdate = ServiceProxy.Create<ICarUpdate>(new Uri("fabric:/App/Car"));
await carUpdate.ProcessCarUpdate();

【讨论】:

  • 这行得通。我现在面临另一个问题,我在 ProcessCarUpdate(delegate) 中传递了一个委托,这个异常被抛出“类型‘System.DelegateSerializationHolder+DelegateEntry’,数据合同名称‘DelegateSerializationHolder.DelegateEntry:schemas.datacontract.org/2004/07/System’不是预期。如果您正在使用 DataContractSerializer 或将任何静态未知的类型添加到已知类型列表中,请考虑使用 DataContractResolver - 例如,通过使用 KnownTypeAttribute 属性或将它们添加到传递给序列化程序的已知类型列表中。"
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-30
  • 1970-01-01
  • 2011-11-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多