In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to integrate kafka in spring-boot 2.1.x. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
Pom.xml configuration:
Org.springframework.boot spring-boot-starter ${spring-boot.version} org.springframework.boot spring-boot-starter-web ${spring-boot.version} org.springframework.boot spring-boot-starter-tomcat Org.springframework.boot spring-boot-starter-undertow ${spring-boot.version} org.springframework.kafka spring-kafka ${kafka.version} org.apache.kafka kafka-clients 2.3.1 com.fasterxml.jackson.core jackson-databind 2.10.0 com.fasterxml.jackson.core jackson-core 2.10.0
Yml configuration:
Spring: kafka: # A comma-separated list of addresses used to establish the initial connection to the Kafka cluster (the default port number of kafka is 9092) bootstrap-servers: 127.0.0.1 bootstrap-servers 9092 producer: # the number of times the message was resent after an error occurred. Retries: 0 # when multiple messages need to be sent to the same partition, the producer will put them in the same batch. This parameter specifies the amount of memory that can be used by a batch, calculated in bytes. Batch-size: 16384 # sets the size of the producer memory buffer. Buffer-memory: 33554432 # key serialization method key-serializer: org.apache.kafka.common.serialization.StringSerializer # value serialization method value-serializer: org.apache.kafka.common.serialization.StringSerializer # acks=0: the producer does not wait for any response from the server before successfully writing the message. # acks=1: as soon as the leader node of the cluster receives a message, the producer will receive a successful response from the server. # acks=all: the producer will receive a successful response from the server only if all the nodes participating in the replication receive the message. Acks: 1 consumer: # autocommit interval in spring boot 2.x version where the value type is Duration needs to conform to a specific format For example, 1Searliest 1M auto-commit-interval 2HJ 5D: 1s # this attribute specifies what consumers should do if they read a partition without offset or if the offset is invalid: # latest (default) if the offset is invalid, the consumer will read the data from the latest record (the record generated after the consumer starts) # earliest: if the offset is invalid The consumer will read the partition's record auto-offset-reset: whether earliest # automatically commits the offset from the starting position. The default is true, in order to avoid duplicate data and data loss. You can set it to false, and then manually submit the offset enable-auto-commit: true # key deserialization mode key-deserializer: org.apache.kafka.common.serialization.StringDeserializer # value deserialization mode value-deserializer: org.apache.kafka.common.serialization.StringDeserializer listener: # the number of threads running in the listener container. Concurrency: 5 after reading the above, do you have any further understanding of how to integrate kafka in spring-boot 2.1.x? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.