Class Restate

java.lang.Object
dev.restate.sdk.Restate

@Experimental public final class Restate extends Object
This class exposes the Restate functionalities to Restate services using the reflection-based API. It can be used to interact with other Restate services, record non-deterministic closures, execute timers, and synchronize with external systems.

This is the entry point for the new reflection-based API where services are defined using annotations and methods can access Restate features through static methods on this class.

Example Usage


 @Service
 public class Greeter {

   @Handler
   public String greet(String input) {
     // Use Restate features via static methods
     String result = Restate.run(
       "external-call",
       String.class,
       () -> externalService.call(input)
     );

     return "You said hi to " + req.name + "!";
   }
 }
 

Error handling

All methods of this class throws either TerminalException or AbortedExecutionException, where the former can be caught and acted upon, while the latter MUST NOT be caught, but simply propagated for clean up purposes.

Serialization and Deserialization

The methods of this class that need to serialize or deserialize payloads have an overload both accepting Class or TypeTag. Depending on your case, you might use the Class overload for simple types, and TypeRef for generic types.

By default, Jackson Databind will be used for all serialization/deserialization. Check SerdeFactory for more details on how to customize that.

Thread safety

This class MUST NOT be accessed concurrently since it can lead to different orderings of user actions, corrupting the execution of the invocation.
See Also: