|
@@ -15,10 +15,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.boot.CommandLineRunner;
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.ResourceUtils;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.File;
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Properties;
|
|
|
import java.util.concurrent.BlockingQueue;
|
|
@@ -98,13 +102,20 @@ public class CloudKafkaConsumerFromEdgeTopic implements CommandLineRunner {
|
|
|
props.put("security.protocol", securtyprotocol);
|
|
|
props.put("ssl.endpoint.identification.algorithm",algorithm);
|
|
|
// properties.put("ssl.truststore.location", ResourceUtils.getFile(truststorelocaltion).getPath());
|
|
|
- // properties.put("ssl.truststore.password", keystorepassword);
|
|
|
- props.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, ResourceUtils.getFile(keystorelocaltion).getPath());
|
|
|
+ // properties.put("ssl.truststore.password", keystorepassword);ResourceUtils.getFile(keystorelocaltion).getPath() ResourceUtils.getFile(truststorelocaltion).getPath()
|
|
|
+ if ("dev".equals(active)){
|
|
|
+
|
|
|
+ }else{
|
|
|
+ props.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, new File(keystorelocaltion).getAbsolutePath());
|
|
|
+ props.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, new File(truststorelocaltion).getAbsolutePath());
|
|
|
+ }
|
|
|
+
|
|
|
props.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG,keystorepassword);
|
|
|
props.put(SslConfigs.SSL_KEY_PASSWORD_CONFIG,keypassword);
|
|
|
- props.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, ResourceUtils.getFile(truststorelocaltion).getPath());
|
|
|
- props.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG,truststorepassword);
|
|
|
|
|
|
+ props.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG,truststorepassword);
|
|
|
+// props.put("sasl.jaas.config",
|
|
|
+// "org.apache.kafka.common.security.scram.ScramLoginModule required username='account_name' password='pwd';");
|
|
|
|
|
|
//metadata.max.age.ms 1000
|
|
|
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
|