./bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic 主题名 --create --partitions 分区数 # 修改主题分区数,分区数只能变大,不能变小 ./bin/\kafka-topics.sh --bootstrap-server localhost:9092 --topic 主题名 --alter --partitions 分区数 # 删除分区 ./bin/kafka-topics.sh --boot...
springboot集成kafka配置方式 1、配置kafka生产者 importlombok.extern.slf4j.Slf4j;importorg.apache.kafka.clients.producer.ProducerConfig;importorg.apache.kafka.common.config.SaslConfigs;importorg.apache.kafka.common.serialization.StringDeserializer;importorg.springframework.beans.factory.annotation.Value;importorg...
return new DefaultKafkaConsumerFactory(twoKafkaProperties.buildConsumerProperties()); } 3、配置消费者监听器工厂,并绑定指定消费者工厂以及消费者配置 @Bean(MultiKafkaConstant.KAFKA_LISTENER_CONTAINER_FACTORY_TWO) public KafkaListenerContainerFactory twoKafkaListenerContainerFactory(@Autowired @Qualifier("twoKafkaP...
@Value("kafka.producer.servers")privateStringservers;@Value("kafka.producer.servers")privateStringservers;@Value("{kafka.producer.retries}") private int retries; @Value("kafka.producer.batch.size")privateintbatchSize;@Value("kafka.producer.batch.size")privateintbatchSize;@Value("{kafka.producer.lin...
application.yml配置:server:port:8080spring:kafka:bootstrap-servers:8.140.246.47:9092producer:# ...
5、配置 kafka springkafka:# kafak服务器地址bootstrap-servers:localhost:9092consumer:# 消费者分组idgroup-id:orde 6、实现消息服务类 packagecom.itheima.service.impl.kafka;importcom.itheima.service.MessageService;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.kafka.core...
# kafkakafka:# kafka 代理地址bootstrap-servers:my-server consumer:# 指定消费者group idgroup-id:my-group# 消费topic主题gourd-topic:my-topic listener:# 在侦听器容器中运行的线程数。concurrency:5ack-mode:MANUAL_IMMEDIATE 配置类 packagecom.jurassic.asset.catalog.config.spring;importorg.apache.kafka.cl...
2. kafka消费者工厂配置 提示:下面属于基础配置,其他配置可以根据业务需求添加 package com.xxx.xxx.config; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.common.serialization.StringDeserializer; import org.springframework.beans.factory.annotation.Value; ...