![]() Key-serializer: .serialization.StringSerializer Value-deserializer: .serialization.StringDeserializer Key-deserializer: .serialization.StringDeserializer serializer = .serialization.StringSerializer deserializer = .serialization.StringDeserializer deserializer= .serialization.StringDeserializer Option 1: Using application.properties or application.ymlĪpplication.properties: -servers = localhost:9092 ![]() There are two ways to configure our Producer and Consumer. ![]() Configurationįirst things first configuration. Last but not least, we will write all our implementations in src > main > java > package. Please note that it may look a little bit different if you choose Maven instead of Gradle when generating the project. Once you generate the project and import it to the IDE you choose, the project structure will be as shown in the picture. In this example, I am going to use IntelliJ IDEA to run the Gradle Spring Boot project. We are going to create a Spring Boot application with Spring Web and Spring for Apache Kafka dependencies and use Spring Initializr to generate our project quickly. If the Kafka server runs without any error as well, we are ready to create a Spring Boot project. Windows users should again use bin\windows\ directory to run the server. bin/kafka-server-start.sh config/server.properties. Simply open a new tab on your command-line interpreter and run the following command to start the Kafka server. If the ZooKeeper instance runs without any error, it is time to start the Kafka server. Since Kafka console scripts are different for Unix-based and Windows platforms, on Windows platforms use bin\windows\instead of bin, and change the script extension to. bin/zookeeper-server-start.sh config/zookeeper.properties ![]() Once you are in the directory of the Kafka folder, kafka_2.12-2.5.0, run the following command to start a single-node ZooKeeper instance. We will use the convenience script packaged as a ZooKeeper server that comes with the Kafka. The good news is that you do not need to download it separately (but you can do it if you want to). % tar -xzf kafka_2.12-2.5.0.tgzĪs I ve already mentioned, the Kafka uses ZooKeeper. Simply open a command-line interpreter such as Terminal or cmd, go to the directory where kafka_2.12-2.5.0.tgz is downloaded and run the following lines one by one without %. ![]() That being said, we will need to install both in order to create this project.įirst, we need to download the source folder of Kafka from here.įirst, download the source folder here. Kafka uses ZooKeeper, an open-source technology that maintains configuration information and provides group services. Today, we will create a Kafka project to publish messages and fetch them in real-time in Spring Boot. Good to know: ZooKeeper is required for running the Kafka right now, but it will be replaced with a Self-Managed Metadata Quorum in the future.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |