3
3
import com .softwaremill .kmq .example .UncaughtExceptionHandling ;
4
4
import org .apache .kafka .clients .producer .KafkaProducer ;
5
5
import org .apache .kafka .clients .producer .ProducerRecord ;
6
+ import org .apache .kafka .clients .CommonClientConfigs ;
6
7
import org .apache .kafka .common .serialization .ByteBufferSerializer ;
8
+ import org .apache .kafka .common .config .SslConfigs ;
7
9
import org .slf4j .Logger ;
8
10
import org .slf4j .LoggerFactory ;
9
11
10
12
import java .io .IOException ;
11
13
import java .nio .ByteBuffer ;
14
+ import java .util .HashMap ;
15
+ import java .util .Map ;
12
16
13
17
import static com .softwaremill .kmq .example .standalone .StandaloneConfig .KAFKA_CLIENTS ;
14
18
import static com .softwaremill .kmq .example .standalone .StandaloneConfig .KMQ_CONFIG ;
@@ -20,6 +24,22 @@ class StandaloneSender {
20
24
21
25
public static void main (String [] args ) throws InterruptedException , IOException {
22
26
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
+ */
23
43
24
44
KafkaProducer <ByteBuffer , ByteBuffer > msgProducer = KAFKA_CLIENTS
25
45
.createProducer (ByteBufferSerializer .class , ByteBufferSerializer .class );
0 commit comments