Tell vs Ask
Use Tell when you don’t need a reply—logging, notifications, commands that trigger side effects. Use Ask when
you need a result—queries, computations, or any flow that depends on the response.
Message types (v4)
From v4.0.0, all message-passing APIs acceptany. You can send:
- Plain Go structs (with CBOR serialization when remote)
- Protocol buffer messages (default ProtoSerializer)
- Any type registered with the serializer
Message ordering
Messages between a specific sender-receiver pair are delivered in the order they were sent (FIFO). This follows from the mailbox being a FIFO queue and the single-threaded processing guarantee per actor.Sender context
InReceive, you can access the sender via ctx.Sender(). It returns a *PID or nil (e.g., for scheduled messages
or when the sender is unknown). Use ctx.Sender().Path() when you need the sender’s address for a reply.
ReceiveContext messaging methods
InsideReceive, the ReceiveContext provides these messaging operations:
Use
Sender() to get the sender’s PID when replying. Use ActorSystem().ActorOf(ctx, name) to resolve an actor by name
before sending.