Reacting in another domain
One domain changes another in one of two ways
(Ownership and calls replace modules):
it calls one of the other domain's public actions, or it emits an event
the other domain subscribes to.
| Public action | Event | |
|---|---|---|
| When | Inside the caller's transaction | After the caller commits |
| If it fails | The caller fails and everything rolls back | Only the subscriber's delivery fails; the emitter is unaffected |
| Who knows whom | The caller names the action | The emitter does not know who listens |
| Use for | Rules that must hold together (reserve stock with the order) | Reactions that may happen later (send the confirmation email) |
The subscriber lives in the domain that reacts, and calls that domain's
own action. The event must be public in the domain that emits it. Here
the notifications domain emails someone when a todo in planning is
completed:
// domains/notifications/subscribers/email_on_completion.jadposubscriber email_on_completion { on: TodoCompleted run: send_completion_email(event)}// domains/notifications/actions/send_completion_email.jadpoaction send_completion_email(event: TodoCompleted) fails EmailRejected -> Unit { ...}
Markdown for agents: /docs/reacting-in-another-domain.md.Built from Jadpo main at a707efb.