In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail the implementation of Docker deployment Kafka and Spring Kafka. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
View the docker-compose.yml in the usage document
Because kafka is used with zookeeper, zookeeper is included in the document
I changed the version number and variable parameters.
These two parameters seem to be exposed to public network access (answers found from other blogs, cannot be connected if you don't set spring kafka)
Run the command docker-compose up-d and two containers will be opened
Enter the kafka container and use the guide on the official website to test http://kafka.apache.org/quickstart.
Docker exec-it {Container id&name} / bin/bash
After entering the container, enter the command directory cd / opt/kafka/bin/
Step 1: create a new topic
Kafka-topics.sh-- create-- bootstrap-server 192.168.17.165 partitions 9092-- replication-factor 1-- partitions 1-- topic mytest (localhost changed to its own ip number)
Step 2: send a message: kafka-console-producer.sh-- broker-list 192.168.17.165-topic mytest
Step 3: open another window for consumption information: kafka-console-consumer.sh-- bootstrap-server 192.168.17.165-from-beginning-- topic mytest-- from-beginning
It means that it has been built successfully.
Start building Spring Kafka
Pom.xml:
Configure producer Config:
Configure Consumer Config
The relevant configuration comes from the spring official website kafka document: https://docs.spring.io/spring-kafka/docs/2.3.1.RELEASE/reference/html/
Send a message after creating a Controller request
Configure snooping:
Using @ KafkaListener annotations, all documents have relevant instructions, so they will not be explained one by one
Run project, and then request url to view the log:
This is the end of the implementation of Docker deployment Kafka and Spring Kafka. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.