1
Get the Greeter service template and run the service
You can choose any of the SDK languages for this quickstart.
You do not need to adapt the handler code to be able to read from Kafka.
Any handler can be connected to Kafka.
2
Running Restate Server
Start the Restate Server:
3
Register the service
Let the Restate Server know about the Greeter service by registering it:
4
Start Kafka and the Kafka ingress integration
Let’s start a Kafka cluster with a single broker, create a topic named The
greetings, and run the Kafka ingress integration next to it.You can run your Kafka cluster in your preferred way. Here, we will use Docker Compose.Create a docker-compose.yaml file with the following content:docker-compose.yaml
restate-kafka-integration container consumes the greetings topic and invokes Greeter/greet for each record.
It reaches the Restate Server running on your machine via host.docker.internal.Start the containers:5
Invoke the handler by publishing an event
Create a Kafka producer and publish an event to the Then type a message and press enter. The greeter takes a String name as an input:For some greeter templates, you might need to send just the name as
greetings topic:"Sarah".6
We invoked a Restate service over Kafka
You now see your handler getting invoked.The way this worked is that the Kafka ingress integration consumed the record from the topic and sent it to Restate, which durably persisted it, similar to what it does for HTTP invocations.It then pushed the message to the handler, as opposed to the pull mechanism that you would have with a Kafka consumer.If the handler fails, Restate will retry the request until it eventually succeeds.Have a look at the Kafka ingress integration docs to learn how to map Kafka records to Restate invocations, connect to secured clusters, and read record metadata in your handler.
Have a look at the Event Processing use case page to learn about what you can do with Restate and event processing.
Related resources
- Event processing use cases: Have a look at examples of how Restate gives you lightweight, transactional event processing.
- Have a look at the examples. There, you can find examples on Durable Execution and event processing.
- Kafka ingress integration reference
- Blog post on Kafka integration