Closed aloneguid closed 7 years ago
You can override the CreateServiceReplicaListeners() method of ActorService to add the message handler like this
class MyActorService : ActorService
{
public MyActorService(
StatefulServiceContext context,
ActorTypeInformation actorTypeInfo,
Func<ActorService, ActorId, ActorBase> actorFactory = null,
Func<ActorBase, IActorStateProvider, IActorStateManager> stateManagerFactory = null,
IActorStateProvider stateProvider = null,
ActorServiceSettings settings = null)
: base(context, actorTypeInfo, actorFactory, stateManagerFactory, stateProvider, settings)
{
}
protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
{
return new[]
{
new ServiceReplicaListener(
context => new FabricTransportActorServiceRemotingListener(
context,
new CorrelatingRemotingMessageHandler(this),
new FabricTransportRemotingListenerSettings()))
};
}
}
And host your actor using this service
ActorRuntime.RegisterActorAsync<SomeActor>(
(context, actorType) => new MyActorService(context, actorType)).GetAwaiter().GetResult();
works like a charm, thank you!
Brilliant piece of code, thank you. I can't figure out though how to initialise message handler for Actors on server side. The client is passing the headers, however where do I place the code in
Actor
implementation to pick them up similar toCreateServiceInstanceListeners()
in reliable services?