| | |
| | | @Value("${spring.kafka.properties.sasl.password}") |
| | | private String saslPassword; |
| | | |
| | | // @Value("${spring.kafka.producer.transaction-id-prefix}") |
| | | // private String transactionIdPrefix; |
| | | |
| | | @Bean |
| | | public Map<String, Object> producerConfigs() { |
| | | Map<String, Object> props = new HashMap<>(); |
| | |
| | | props.put("sasl.username", saslUsername); |
| | | props.put("sasl.password", saslPassword); |
| | | |
| | | |
| | | // props.put("sasl.jaas.config", "org.apache.kafka.common.security.scram.ScramLoginModule required username='sc001' password='wCV0ISwmoKwbx1lpBKMW';"); |
| | | |
| | | |
| | | props.put("sasl.jaas.config", saslJaasConfig); |
| | | |
| | | return props; |
| | |
| | | DefaultKafkaProducerFactory<String, String> producerFactory = new DefaultKafkaProducerFactory<>(producerConfigs()); |
| | | return producerFactory; |
| | | } |
| | | |
| | | // @Bean |
| | | // public ProducerFactory<Object, Object> producerFactory() { |
| | | // DefaultKafkaProducerFactory<Object, Object> factory = new DefaultKafkaProducerFactory<>(producerConfigs()); |
| | | // //开启事务,会导致 LINGER_MS_CONFIG 配置失效 |
| | | // // factory.setTransactionIdPrefix(transactionIdPrefix); |
| | | // return factory; |
| | | // } |
| | | |
| | | // @Bean |
| | | // public KafkaTransactionManager<Object, Object> kafkaTransactionManager(ProducerFactory<Object, Object> producerFactory) { |
| | | // return new KafkaTransactionManager<>(producerFactory); |
| | | // } |
| | | |
| | | @Bean |
| | | public KafkaTemplate<String, String> kafkaTemplate(ProducerFactory<String, String> producerFactory) { |