Try CoAkka when you use NATS

Start with one internal call that is easy to verify. If the workflow depends on retained events and replay, decide where those events will live first.

How do CoAkka Runtime and NATS differ?

Application A asks B for a price and waits for one result. With NATS, the call goes through a NATS Server. CoAkka Runtime in Peer mode lets A call B directly while pricing stays in a separate process.

Through NATS
Application A → NATS Server → Pricing in B
CoAkka Runtime · Peer
Application A → Pricing in B
CoAkka Runtime · Embedded
Application A → Pricing in A

Try switching just the pricing call. Keep JetStream on workflows that need retention and replay during the trial.

What does application A get back?

When B finishes, A receives the quote. If CoAkka Runtime accepted the request but found no route, A receives a Deadletter with reason ROUTE_MISS and the original envelope, including payload data such as the basket ID.

This is the outcome of the internal call. An external HTTP API, when present, chooses the status it returns to its client.

Using the reason and original data, the application can record work for review in a database, add it to a pending-work list, or forward it to an existing system that handles the work.

Choose what to save and when to retry
  • If the request is refused before admission, handle the error at submission.
  • For ROUTE_MISS, keep the work ID, the reason, and the data you need. Check and repair routing before you retry.
  • After a timeout, B may already have processed the work. Reconcile the business result before resending an operation with side effects, such as charging a payment.
  • If work must survive an application stop before it can read the result, choose a way to record it durably before sending.

See the Deadletter fields.

Criteria CoAkka Runtime Core NATS JetStream
App integration The app integrates a connector and registers handlers by name. The app uses a client to connect to a separate NATS Server. Enable storage on the NATS Server. The app publishes on a subject to store messages in a stream, then reads through a consumer.
Delivery path Within one process (Embedded) or directly between two processes (Peer). Sender → NATS Server → active subscribers. Sender → stream on a NATS Server → reader, possibly at a later time.
Send and receive Address work by its target name. Ask and wait for a reply, or send one-way. Address messages by subject. Request a reply, publish to subscribers, or share work within a queue group. Track each consumer’s progress. Unacknowledged messages can be redelivered according to its configuration.
Multiple instances The app or platform supplies B1 and B2. CoAkka Runtime selects an eligible peer using the configured routes. NATS servers connect to route messages across the cluster. Each queue group delivers to one active subscriber in the group. Streams and consumer state can be replicated within the NATS cluster. Server-loss tolerance depends on the configured replica count and available replicas.
Storage and replay The app chooses durable storage when work must survive failure or history must be replayable. Delivery goes to subscribers connected at publication time. Use JetStream for retention and replay. Store stream messages according to the retention policy. Readers can resume or replay retained data.
Good fit An app needs to call internal work, such as pricing a basket. Multiple apps communicate over subjects, for example to receive live price updates. Inventory and reporting need to read the same orders.created event at their own pace.

Choose where to retain work

If work must survive a process restart, decide where it is recorded before migrating the flow. A database-backed design inherits that database’s durability and recovery configuration.

Requirement Option
Work must run after the order commits Transactional outbox. Write the order and pending work in the same transaction. A worker dispatches committed items. Use a stable work ID to handle redelivery safely.
Rebuild reports from history Event table. Define retention, the ordering you need, and each reader’s checkpoint. Account for writes and replay load on the database.
Independent groups need replay Keep JetStream. Keep streams and consumers that already meet the requirement. Try CoAkka Runtime on the separate pricing call.
Check worker restart and redelivery

Keep committed records when the worker stops. On restart it picks up pending work. If a receiver finished before the worker could mark the item complete, it may receive the same work again. Reuse the work ID and verify the business effect happens once.

Run both Worker exit cases locally.

Measure database write latency, backlog size, and catch-up time. If you need historical replay, verify recovery from a reader checkpoint separately.

Try one internal call

  1. Pick pricing or another read-only call with a clear result. Identify the recipients and the guarantees the workflow relies on today.
  2. Try the same data and load in staging. Use Embedded for a handler in the same process or Peer to keep two processes. Keep the NATS path available for rollback.
  3. Compare results, errors, and p99. Stop the handler and check the outcome. Count the resources you can actually remove while other workflows still use NATS.
Source documentation