Skip to content

Commit b1a7be7

Browse files
authored
Update StandaloneSender.java
1 parent a644951 commit b1a7be7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

example-java/src/main/java/com/softwaremill/kmq/example/standalone/StandaloneSender.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
import com.softwaremill.kmq.example.UncaughtExceptionHandling;
44
import org.apache.kafka.clients.producer.KafkaProducer;
55
import org.apache.kafka.clients.producer.ProducerRecord;
6+
import org.apache.kafka.clients.CommonClientConfigs;
67
import org.apache.kafka.common.serialization.ByteBufferSerializer;
8+
import org.apache.kafka.common.config.SslConfigs;
79
import org.slf4j.Logger;
810
import org.slf4j.LoggerFactory;
911

1012
import java.io.IOException;
1113
import java.nio.ByteBuffer;
14+
import java.util.HashMap;
15+
import java.util.Map;
1216

1317
import static com.softwaremill.kmq.example.standalone.StandaloneConfig.KAFKA_CLIENTS;
1418
import static com.softwaremill.kmq.example.standalone.StandaloneConfig.KMQ_CONFIG;
@@ -20,6 +24,22 @@ class StandaloneSender {
2024

2125
public static void main(String[] args) throws InterruptedException, IOException {
2226
UncaughtExceptionHandling.setup();
27+
28+
/* EXAMPLE with extraConfig : SSL Encryption & SSL Authentication
29+
Map extraConfig = new HashMap();
30+
//configure the following three settings for SSL Encryption
31+
extraConfig.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL");
32+
extraConfig.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, "/directory/kafka.client.truststore.jks");
33+
extraConfig.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "test1234");
34+
35+
// configure the following three settings for SSL Authentication
36+
extraConfig.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, "/directory/kafka.client.keystore.jks");
37+
extraConfig.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, "test1234");
38+
extraConfig.put(SslConfigs.SSL_KEY_PASSWORD_CONFIG, "test1234");
39+
40+
KafkaProducer<ByteBuffer, ByteBuffer> msgProducer = KAFKA_CLIENTS
41+
.createProducer(ByteBufferSerializer.class, ByteBufferSerializer.class, extraConfig);
42+
*/
2343

2444
KafkaProducer<ByteBuffer, ByteBuffer> msgProducer = KAFKA_CLIENTS
2545
.createProducer(ByteBufferSerializer.class, ByteBufferSerializer.class);

0 commit comments

Comments
 (0)