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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot