Merge remote-tracking branch 'remotes/origin/usemongo' into kafka

This commit is contained in:
Nicolas Héron 2020-10-08 19:03:26 +02:00
commit f23eec8ec3
12 changed files with 226 additions and 5 deletions

View file

@ -17,3 +17,11 @@ spring.data.mongodb.username=${PYMMA_MONGO_USERNAME}
spring.servlet.multipart.enabled=false
kafka.bootstrapAddress=${PYMMA_KAFKA_BOOTSTRAP:kafka1:19092,kafka2:19093,kafka3:19094}
pymma.kafka.activateSsl=${PYMMA_KAFKA_ACTIVATE_SSL:false}
pymma.kafka.sslTruststoreLocation=${PYMMA_KAFKA_SSL_TRUSTSTORE_LOCATION:}
pymma.kafka.sslTruststorePassword=${PYMMA_KAFKA_SSL_TRUSTSTORE_PASSWORD:}
pymma.kafka.sslKeyPassword=${PYMMA_KAFKA_KEY_PASSWORD:}
pymma.kafka.sslKeystorePassword=${PYMMA_KAFKA_SSL_KEYSTORE_PASSWORD:}
pymma.kafka.sslKeystoreLocation=${PYMMA_KAFKA_SSL_KEYSTORE_LOCATION:}
pymma.kafka.sslKeystoreType=${PYMMA_KAFKA_SSL_KEYSTORE_TYPE:}

View file

@ -2,10 +2,13 @@ package org.chtijbug.drools.console;
import com.vaadin.flow.spring.SpringServlet;
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.clients.admin.AdminClientConfig;
import org.apache.kafka.clients.admin.NewTopic;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.config.SslConfigs;
import org.apache.kafka.common.security.auth.SecurityProtocol;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.kafka.common.serialization.StringSerializer;
import org.chtijbug.drools.KieContainerResponse;
@ -65,6 +68,27 @@ public class DroolsSpringBootConsoleApplication extends SpringBootServletInitial
@Value(value = "${kafka.bootstrapAddress}")
private String bootstrapAddress;
@Value("${pymma.kafka.activateSsl:false}")
private boolean activateSsl;
@Value("${pymma.kafka.sslTruststoreLocation:}")
private String sslTruststoreLocation;
@Value("${pymma.kafka.sslTruststorePassword:}")
private String sslTruststorePassword;
@Value("${pymma.kafka.sslKeyPassword:}")
private String sslKeyPassword;
@Value("${pymma.kafka.sslKeystorePassword:}")
private String sslKeystorePassword;
@Value("${pymma.kafka.sslKeystoreLocation:}")
private String sslKeystoreLocation;
@Value("${pymma.kafka.sslKeystoreType:}")
private String sslKeystoreType;
@Autowired
private DababaseContentInit dababaseContentInit;
@Autowired
@ -113,6 +137,15 @@ public class DroolsSpringBootConsoleApplication extends SpringBootServletInitial
public KafkaAdmin kafkaAdmin() {
Map<String, Object> configs = new HashMap<>();
configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress);
if (activateSsl) {
configs.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, SecurityProtocol.SSL.name);
configs.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, this.sslTruststoreLocation);
configs.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, this.sslTruststorePassword);
configs.put(SslConfigs.SSL_KEY_PASSWORD_CONFIG, this.sslKeyPassword);
configs.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, this.sslKeystorePassword);
configs.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, this.sslKeystoreLocation);
configs.put(SslConfigs.SSL_KEYSTORE_TYPE_CONFIG, this.sslKeystoreType);
}
return new KafkaAdmin(configs);
}
@ -133,6 +166,15 @@ public class DroolsSpringBootConsoleApplication extends SpringBootServletInitial
configProps.put(
ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
JsonSerializer.class);
if (activateSsl) {
configProps.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, SecurityProtocol.SSL.name);
configProps.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, this.sslTruststoreLocation);
configProps.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, this.sslTruststorePassword);
configProps.put(SslConfigs.SSL_KEY_PASSWORD_CONFIG, this.sslKeyPassword);
configProps.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, this.sslKeystorePassword);
configProps.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, this.sslKeystoreLocation);
configProps.put(SslConfigs.SSL_KEYSTORE_TYPE_CONFIG, this.sslKeystoreType);
}
return new DefaultKafkaProducerFactory<>(configProps);
}
@ -229,7 +271,7 @@ public class DroolsSpringBootConsoleApplication extends SpringBootServletInitial
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("org.chtijbug.drools.console.restExpose"))
.apis(RequestHandlerSelectors.basePackage("org.chtijbug.drools.console.restexpose"))
//.paths(PathSelectors.regex("/api/wb./wb.*"))
.paths(PathSelectors.regex("/api/wb.*"))
.build()

View file

@ -18,3 +18,11 @@ spring.servlet.multipart.enabled=false
kafka.bootstrapAddress=${PYMMA_KAFKA_BOOTSTRAP:localhost:9092,localhost:9093,localhost:9094}
vaadin.urlMapping=/admin/*
pymma.kafka.activateSsl=${PYMMA_KAFKA_ACTIVATE_SSL:false}
pymma.kafka.sslTruststoreLocation=${PYMMA_KAFKA_SSL_TRUSTSTORE_LOCATION:}
pymma.kafka.sslTruststorePassword=${PYMMA_KAFKA_SSL_TRUSTSTORE_PASSWORD:}
pymma.kafka.sslKeyPassword=${PYMMA_KAFKA_KEY_PASSWORD:}
pymma.kafka.sslKeystorePassword=${PYMMA_KAFKA_SSL_KEYSTORE_PASSWORD:}
pymma.kafka.sslKeystoreLocation=${PYMMA_KAFKA_SSL_KEYSTORE_LOCATION:}
pymma.kafka.sslKeystoreType=${PYMMA_KAFKA_SSL_KEYSTORE_TYPE:}