首页 > 编程语言> > c# – RunAsync中的Spawning actor抛出“对象’CustomActorService.InternalCustomActorService’未实现接口id’1830616258
c# – RunAsync中的Spawning actor抛出“对象’CustomActorService.InternalCustomActorService’未实现接口id’1830616258
作者:互联网
我正在遵循Service Fabric spawn actor on startup中的建议,在服务开始时产生几个演员.我有一个自定义的ActorService子类,其中包含以下RunAsync覆盖:
internal sealed class InternalCustomActorService : ActorService
{
protected async override Task RunAsync(CancellationToken cancellationToken)
{
await base.RunAsync(cancellationToken);
for(int i = 0; i < 10; i++)
{
ICustomActor proxy = ActorProxy.Create<ICustomActor>(new ActorId(i));
await proxy.StartAsync();
}
}
...
该类在Program.cs中注册如下:
ActorRuntime.RegisterActorAsync<CustomActor>(
(context, actorType) => new InternalCustomActorService(context, actorType, () => new CustomActor())).GetAwaiter().GetResult();
但是,我收到以下异常调用proxy.StartAsync()方法:
FatalExecutionEngineError occurred
HResult=-2146233088
Message=One or more errors occurred.
Source=Microsoft.ServiceFabric.Services
StackTrace:
at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1.<InvokeWithRetryAsync>d__7`1.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Services.Remoting.Client.ServiceRemotingPartitionClient.<InvokeAsync>d__8.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<InvokeAsync>d__0.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<ContinueWith>d__b.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at CustomActorService.InternalCustomActorService.<RunAsync>d__2.MoveNext() in C:\_data\Master\CONSTABLE2\Apps\BSP\Research\ServiceFabric\CustomActorServiceApp\CustomActorService\InternalCustomActorService.cs:line 47
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Services.Runtime.StatefulServiceReplicaAdapter.<ExecuteRunAsync>d__e.MoveNext()
InnerException:
HResult=-2147467263
Message=Interface id '1830616258' is not implemented by object 'CustomActorService.InternalCustomActorService'
Source=Microsoft.ServiceFabric.Services
InnerException:
示例项目位于GitHub https://github.com/PaloMraz/CustomActorServiceApp
我的问题是:我做错了什么?
编辑:我试图添加额外的BootstrapperService无状态服务,并从BootstrapperService.RunAsync中产生演员:
protected override async Task RunAsync(CancellationToken cancellationToken)
{
await base.RunAsync(cancellationToken);
await Task.Delay(10000);
for (int i = 0; i < 10; i++)
{
ICustomActor proxy = ActorProxy.Create<ICustomActor>(new ActorId(i));
await proxy.StartAsync();
}
}
尽管如此,对proxy.StartAsync()的调用会抛出与上面的InternalCustomActorService.RunAsync中完全相同的异常.
解决方法:
从自定义actor服务中删除以下代码:
protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
{
var remotingListener = new ServiceReplicaListener(context => this.CreateServiceRemotingListener(context));
return new ServiceReplicaListener[] { remotingListener };
}
这是删除基础ActorService正在设置的ActorRemotingListener.如果要添加其他侦听器,请调用基本CreateServiceReplicaListeners方法,获取侦听器,然后添加自定义侦听器.
标签:c,azure-service-fabric,service-fabric-actor 来源: https://codeday.me/bug/20190628/1310962.html