- Request-response calls: Call and wait for a response
- One-way messages: Send a message and continue
- Delayed messages: Send a message after a delay
To call a service from an external application, see the HTTP, Kafka, or SDK Clients documentation.
Generating service clients
The Restate Java SDK automatically generates clients for each of your services when you build the project. If you don’t see the generated clients, make sure you added the code generator and have built the project with./gradlew build
or mvn compile exec:java
.
Request-response calls
To call a Restate handler, use the generated clients and wait for its result:Workflow retention
Workflow retention
After a workflow’s run handler completes, other handlers can still be called for up to 24 hours (default).
Update this via the service configuration.
Request-response calls between exclusive handlers of Virtual Objects may lead to deadlocks:
- Cross deadlock: A → B and B → A (same keys).
- Cycle deadlock: A → B → C → A.
Sending messages
To send a message to another Restate handler without waiting for a response:Calls to a Virtual Object execute in order of arrival, serially.
Example:Call A is guaranteed to execute before B. However, other invocations may interleave between A and B.
Delayed messages
To send a message after a delay, use the generated clients with.send()
and the Duration
as second parameter:
Learn how this is different from sleeping and then sending a message.
Using an idempotency key
To prevent duplicate executions of the same call, add an idempotency key:Attach to an invocation
To wait for or get the result of a previously sent message:- With an idempotency key: Wait for completion and retrieve the result.
- Without an idempotency key: Can only wait, not retrieve the result.
Cancel an invocation
To cancel a running handler:See also
- SDK Clients: Call Restate services from external applications
- Error Handling: Handle failures and terminal errors in service calls
- Durable Timers: Implement timeouts for your service calls
- Serialization: Customize how data is serialized between services
- Sagas: Roll back or compensate for canceled service calls.