我已经为此苦苦挣扎了几天,需要一些帮助。我们有一个报告服务,它根据用户选择使用来自 Rabbit MQ 的消息来运行报告。当然,有些报告比其他报告需要更长的时间,我们正在使用可靠的参与者来完成这些报告请求的工作。
在我们的界面中,我们将 Remoting Listener 版本和客户端版本都设置为 V2.1,并将操作超时秒数设置为几个小时:
这没有任何问题(从我的角度来看),当我们使用 actor 代理调用我们的 actor 时,一切都可以正常工作。
var actorService = ActorProxy.Create<IReportsWorker>(new ActorId(key));
successful = await actorService.CreateReport(reportEvent.CustomerId, reportEvent.ReportQueueId);
但是,我们不能在运行时将操作超时秒字段更改为可从我们的数据库进行配置。
并想出了以下内容:
ServiceUriBuilder builder = new ServiceUriBuilder("Reports", "ReportsWorkerActorService");
string actorURI = builder.ToUri().ToString();
ServiceProxyDistributorCached _ServiceProxyDistributorCached = new ServiceProxyDistributorCached(_logger, builder.ToUri().ToString());
ServicePartitionKey partition = _ServiceProxyDistributorCached.GetKey(System.Fabric.ServicePartitionKind.Int64Range, builder.ToUri().ToString());
long key = (long)partition.Value;
int Minutes = _appConfig.GetPlatformSetting("ReportOperationTimeOutMinutes") == string.Empty ? 60 : int.Parse(_appConfig.GetPlatformSetting("ReportOperationTimeOutMinutes"));
FabricTransportRemotingSettings transportSettings = new FabricTransportRemotingSettings
{
OperationTimeout = TimeSpan.FromMinutes(Minutes),
UseWrappedMessage = true
};
IServiceRemotingClientFactory clientFactory = new FabricTransportServiceRemotingClientFactory(transportSettings);
////ActorProxyFactory actorProxyFactory = new ActorProxyFactory((c) => new FabricTransportServiceRemotingClientFactory(transportSettings));
ActorProxyFactory actorProxyFactory = new ActorProxyFactory((c) => clientFactory);
var actorService = actorProxyFactory.CreateActorProxy<IReportsWorker>(new ActorId(key));
我收到以下异常:
System.Runtime.Serialization.SerializationException: Type 'Microsoft.ServiceFabric.Actors.Remoting.V2.ActorRemotingMessageHeaders' with data contract name 'ActorHeader:urn:actors' is not expected. Consider using a DataContractResolver if you are using DataContractSerializer or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to the serializer.
我不知道我在这里做错了什么,因为我在 SDK 中看不到任何允许我指定 V2.1 ActoryProxyFactory 的东西。我不想更改侦听器版本。
欢迎提出想法和想法!