Skip to main content
Restate services can run in two ways: as an HTTP endpoint or as AWS Lambda functions.

Creating an HTTP endpoint

  1. Use either or as SDK dependency.
  2. Create an endpoint
  3. Bind one or multiple services to it
  4. Listen on the specified port (default 9080) for connections and requests.
import dev.restate.sdk.endpoint.Endpoint;
import dev.restate.sdk.http.vertx.RestateHttpServer;

class MyApp {
  public static void main(String[] args) {
    RestateHttpServer.listen(
        Endpoint.bind(new MyService()).bind(new MyObject()).bind(new MyWorkflow()), 8080);
  }
}

Creating a Lambda handler

  1. Use either or as SDK dependency.
  2. Extend the class BaseRestateLambdaHandler
  3. Override the register method
  4. Bind one or multiple services to the builder
import dev.restate.sdk.endpoint.Endpoint;
import dev.restate.sdk.lambda.BaseRestateLambdaHandler;

class MyLambdaHandler extends BaseRestateLambdaHandler {
  @Override
  public void register(Endpoint.Builder builder) {
    builder.bind(new MyService()).bind(new MyObject());
  }
}
The implementation of your services and handlers remains the same for both deployment options. Have a look at the deployment section for guidance on how to deploy your services on AWS Lambda.
If you use a JVM >= 21, you can use virtual threads to run your services:
builder.bind(
    new Greeter(),
    HandlerRunner.Options.withExecutor(Executors.newVirtualThreadPerTaskExecutor()));

Troubleshooting HTTP/2 with Spring Boot

Restate communicates with your service over HTTP/2 bidirectional streaming. When using the Java/Kotlin SDK with Spring Boot, you may encounter errors such as:
[META0003] error when calling 'http://app:9080/': h2 pool connection error: stream closed because of a broken pipe
This is most often caused by a misaligned Netty version pulled in by the Spring Parent POM or the Gradle dependency management plugin, not by the embedded servlet container. The Restate Java SDK ships its own HTTP server (RestateHttpServer from sdk-http-vertx); it does not use Spring Boot’s embedded Tomcat for the Restate endpoint.

Force the correct Netty version

Pin Netty to a version compatible with the SDK’s bundled Vert.x.
<properties>
    <netty.version>4.1.124.Final</netty.version>
</properties>

Disable bidirectional streaming as a workaround

If your environment cannot reliably carry HTTP/2 streams (for example, an intermediate proxy that closes idle HTTP/2 connections), you can fall back to request-response mode:
var handler = HttpEndpointRequestHandler.fromEndpoint(
    Endpoint.builder().bind(new MyService()).build(),
    /* disableBidirectionalStreaming */ true);
RestateHttpServer.listen(handler);
Bidirectional streaming is recommended whenever possible because it lets a single deployment handle multiple concurrent invocations over one connection. Disable it only when you cannot fix the underlying HTTP/2 path.

Validating request identity

SDKs can validate that incoming requests come from a particular Restate instance. You can find out more about request identity in the Security docs. You will need to use the request identity dependency .
import dev.restate.sdk.auth.signing.RestateRequestIdentityVerifier;
import dev.restate.sdk.endpoint.Endpoint;
import dev.restate.sdk.http.vertx.RestateHttpServer;

class MySecureApp {
  public static void main(String[] args) {
    var endpoint =
        Endpoint.bind(new MyService())
            .withRequestIdentityVerifier(
                RestateRequestIdentityVerifier.fromKeys(
                    "publickeyv1_w7YHemBctH5Ck2nQRQ47iBBqhNHy4FV7t2Usbye2A6f"));
    RestateHttpServer.listen(endpoint);
  }
}