Code of the Sample Project
Producer
DMS Kafka APIs are compatible with native open-source Kafka clients. Compared with native Kafka service code, the sample project code additionally contains a client certificate and simple authentication and security layer (SASL) configuration, which are used for identity authentication and secure communication. To realize smooth migration of producer applications, you only need to import the client certificate and SASL configuration before creating the Kafka Producer without modifying any other Kafka service code.
Code pertaining to client certificate and SASL:
Properties producerConfig = Config.getProducerConfig();
producerConfig.put("ssl.truststore.location", Config.getTrustStorePath());
System.setProperty("java.security.auth.login.config", Config.getSaslConfig()); The code for creating a producer and sending messages does not need to be modified.
Consumer
DMS Kafka APIs are compatible with native open-source Kafka clients. Compared with native Kafka service code, the sample project code additionally contains a client certificate and SASL configuration, which are used for identity authentication and secure communication. To realize smooth migration of consumer applications, you only need to import the client certificate and SASL configuration before creating the Kafka Consumer without modifying any other Kafka service code.
Code pertaining to client certificate and SASL:
Properties consumerConfig = Config.getConsumerConfig();
consumerConfig.put("ssl.truststore.location", Config.getTrustStorePath());
System.setProperty("java.security.auth.login.config", Config.getSaslConfig()); The code for creating a consumer and consuming messages does not need to be modified.
Last Article: Compiling the Sample Project Code
Next Article: Using the Enhanced Java SDK
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.