Skip to main content

Actor context

Ask for a typed context in the actor constructor. Nixie provides it automatically:

public sealed class ParentActor : IActor<string>
{
private readonly IActorContext<ParentActor, string> context;
private readonly IActorRef<ChildActor, string> child;

public ParentActor(IActorContext<ParentActor, string> context)
{
this.context = context;
child = context.ActorSystem.Spawn<ChildActor, string>();
}

public Task Receive(string message)
{
child.Send(message, context.Self);
return Task.CompletedTask;
}
}
MemberPurpose
ActorSystemThe system that owns the actor.
SelfA typed reference to the current actor.
SenderThe supplied sender reference, when present.
LoggerThe logger configured on the actor system.
OnPostShutdownRegister cleanup work after shutdown.

Request/response contexts also expose Reply and ByPassReply for advanced reply flows.

:::note Execution context isolation Actor handlers run on the default ExecutionContext. Ambient sender values such as AsyncLocal do not flow into the handler. Put request-scoped data in the message explicitly. :::