Developer Advocate (Presenter)
This exercise sets up a new Spring Boot project with Spring for Apache Kafka and connects it with Confluent Cloud.
Go to start.spring.io and add a new project, selecting Gradle, Java, and the default version of Spring Boot.
Add your project’s metadata as Group: ”io.confluent.developer,” Artifact: “spring-ccloud,” Description: “Demo project for Spring Boot with Confluent Cloud,” and Package Name: “io.confluent.developer.spring.”
Select Jar packaging and Java 11.
Click the Add Dependencies button and add Spring for Apache Kafka, Spring for Apache Kafka Streams, Cloud Stream, Lombok, and Spring Reactive Web.
Click Generate to download a ZIP archive. In your terminal, unzip the file:
unzip spring-ccloud.zip
Then open the spring-ccloud
directory in your IDE.
Now, open a browser and navigate to Confluent Cloud (if you don’t have an account, you can sign up for a free trial (details) and use the promo code SPRING101
for an additional $25 of free usage).
In the default environment, go to Add Cluster, then create a Basic cluster, and click Begin configuration.
Copy the “#Kafka” section of your config, click Done, and then go back to your IDE with Spring.
---
# Kafka
spring.kafka.properties.sasl.mechanism=PLAIN
spring.kafka.properties.bootstrap.servers=pkc-lzvrd.us-west4.gcp.confluent.cloud:9092
spring.kafka.properties.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username='{{ CLUSTER_API_KEY }}' password='{{ CLUSTER_API_SECRET }}';
spring.kafka.properties.security.protocol=SASL_SSL
Under src/main/resources/application.properties
, paste the config.
We will only share developer content and updates, including notifications when new content is added. We will never send you sales emails. 🙂 By subscribing, you understand we will process your personal information in accordance with our Privacy Statement.