How is a named target different from an actor?

A named target identifies a piece of work, such as billing.quote for pricing a basket. CoAkka Runtime uses that name to route a request to a handler. In Akka, an ActorRef refers to an actor with its own behavior and lifecycle.

Checkout calls billing.quote

In the lab, Node.js sends a quantity of 3 to billing.quote. CoAkka Runtime selects an endpoint using the configured route. The Python handler prices 3 items at $12.00 each and the $36.00 reply is delivered back to Node.js.

Embedded in one process
Checkout → billing.quote → pricing handler in the same application → $36.00
Peer in a separate process
Node.js checkout → billing.quote → CoAkka Runtime delivers to the Python process → $36.00

The Embedded path illustrates the same calculation with the handler inside the checkout application. Moving to a peer changes the route to point to the Python process. The target name, request data, and reply format can stay the same.

Compare named targets and actors

Question Named target in CoAkka Runtime Actor in Akka
How is the recipient selected? The target name selects a route. That route can point to one or more endpoints that handle the same work. A message is sent through an ActorRef, a reference to the actor that will receive it.
Where does state live? The application chooses where to keep its business data. The pricing handler can read a price list from memory or a database. An actor can hold its own state and update it as it handles messages.
What orders two requests? Two requests for the same target can reach different eligible endpoints. If the business needs per-order sequencing, the application enforces it. An actor processes one message at a time from its mailbox, the actor's message queue. This applies to an individual actor.
Who manages lifecycle and failure? The application manages its handler and process. CoAkka Runtime manages routing and delivery. A missing route can produce a Deadletter for the call. The actor system manages actor lifecycles. A supervision policy determines what happens when an actor fails, such as stopping or restarting it.

Handle updates that need per-order sequencing

Price requests only read data, so they can run independently. To confirm an order, send the order ID and the cart version that was quoted. The handler updates the order only if the version still matches and the order is still unconfirmed. Apply both conditions in the same database update so only one of 2 concurrent requests can confirm the order.

If a route is missing, check the CoAkka Runtime configuration. If the order is rejected because the version changed, read the business reply and check the cart state.

When an application already uses actors

If an actor already holds an order's state and processes updates in sequence, keep that actor in charge of the order. A CoAkka Runtime handler can forward the request to the corresponding actor using the order ID. The actor continues to enforce the order's rules.

References