| | |
| | | @Configuration |
| | | @EnableKafka |
| | | public class KafkaConsumerConfig { |
| | | @Value("${kafka.consumer.servers}") |
| | | @Value("47.99.145.48:9092,47.111.116.38:9092,47.111.124.159:9092") |
| | | private String servers; |
| | | @Value("${kafka.consumer.enable.auto.commit}") |
| | | private boolean enableAutoCommit; |
| | |
| | | @Value("${kafka.groupId.state}") |
| | | private String stateGroupId; |
| | | |
| | | @Bean |
| | | @Bean("insertListenerContainerFactory") |
| | | public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<String, String>> insertListenerContainerFactory() { |
| | | ConcurrentKafkaListenerContainerFactory<String, String> factory = new ConcurrentKafkaListenerContainerFactory<>(); |
| | | factory.setConsumerFactory(insertConsumerFactory()); |
| | |
| | | return factory; |
| | | } |
| | | |
| | | @Bean |
| | | @Bean("stateListenerContainerFactory") |
| | | public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<String, String>> stateListenerContainerFactory() { |
| | | ConcurrentKafkaListenerContainerFactory<String, String> factory = new ConcurrentKafkaListenerContainerFactory<>(); |
| | | factory.setConsumerFactory(stateConsumerFactory()); |
| | |
| | | } |
| | | |
| | | /* |
| | | * 通用配置 |
| | | * */ |
| | | * 通用配置 |
| | | * */ |
| | | public Map<String, Object> consumerConfigs() { |
| | | Map<String, Object> propsMap = new HashMap<>(); |
| | | propsMap.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, servers); |