Chapter 24: Temporal basics for the watcher
| Concept | Use in the watcher |
|---|---|
| Workflow | One watcher run |
| Activity | One model call, one tool call, one alert post |
| Signal | Human approval |
| Timer | Approval deadline |
| Retry policy | Retry a failed model or tool call |
| Query | Read the current state |
Determinism rule. Workflow code must give the same result on replay. Model calls, tool calls, database writes, and REST calls go in activities. Use Workflow.await, Workflow.sleep, and Workflow.currentTimeMillis() in the workflow. Do not use Thread.sleep or Instant.now() there.
Thread.sleep and Instant.now() never appear in workflow code.@WorkflowInterface
public interface WatcherWorkflow {
@WorkflowMethod RunResult run(WatchRequest request);
@SignalMethod void decideApproval(boolean approved);
@QueryMethod String state();
}
Verify: Confirm the annotation packages and the starter configuration keys for SDK 1.35.0. Temporal’s Spring Boot starter starts the worker automatically when the app starts.
Exercise. Start a run through a REST endpoint. Read its state with a query. Approve a critical run. Confirm one alert posts.