修改kafka配置
This commit is contained in:
@@ -51,25 +51,7 @@ public class KafkaConfig {
|
|||||||
|
|
||||||
return new KafkaTemplate<>(factory);
|
return new KafkaTemplate<>(factory);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
@Bean(name = "dccConsumerFactory")
|
|
||||||
public ConcurrentKafkaListenerContainerFactory<String, String> dccConsumerFactory(
|
|
||||||
@Value("${kafka.dcc.bootstrap-servers}") String bootstrapServers,
|
|
||||||
@Value("${kafka.dcc.consumer.group}") String groupId,
|
|
||||||
@Value("${kafka.dcc.consumer.key-deserializer}") String keyDeserializer,
|
|
||||||
@Value("${kafka.dcc.consumer.value-deserializer}") String valueDeserializer) {
|
|
||||||
Map<String, Object> props = new HashMap<>();
|
|
||||||
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
|
|
||||||
props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
|
|
||||||
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, keyDeserializer);
|
|
||||||
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, valueDeserializer);
|
|
||||||
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
|
|
||||||
ConcurrentKafkaListenerContainerFactory<String, String> factory =
|
|
||||||
new ConcurrentKafkaListenerContainerFactory<>();
|
|
||||||
factory.setConsumerFactory(new DefaultKafkaConsumerFactory<>(props));
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@Bean(name = "analyticCenterConsumerFactory")
|
@Bean(name = "analyticCenterConsumerFactory")
|
||||||
public ConcurrentKafkaListenerContainerFactory<String, String> analyticCenterConsumerFactory(
|
public ConcurrentKafkaListenerContainerFactory<String, String> analyticCenterConsumerFactory(
|
||||||
@Value("${analyticCenterKafka.bootstrap-servers}") String bootstrapServers,
|
@Value("${analyticCenterKafka.bootstrap-servers}") String bootstrapServers,
|
||||||
@@ -83,6 +65,8 @@ public class KafkaConfig {
|
|||||||
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, valueDeserializer);
|
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, valueDeserializer);
|
||||||
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
|
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
|
||||||
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
|
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
|
||||||
|
props.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, 60000); // 会话1分钟
|
||||||
|
props.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, 300000); // 可选:允许更长的消费间隔
|
||||||
ConcurrentKafkaListenerContainerFactory<String, String> factory =
|
ConcurrentKafkaListenerContainerFactory<String, String> factory =
|
||||||
new ConcurrentKafkaListenerContainerFactory<>();
|
new ConcurrentKafkaListenerContainerFactory<>();
|
||||||
factory.setConsumerFactory(new DefaultKafkaConsumerFactory<>(props));
|
factory.setConsumerFactory(new DefaultKafkaConsumerFactory<>(props));
|
||||||
|
|||||||
Reference in New Issue
Block a user