Refactor logging to use slf4j
[iotivity.git] / cloud / messagequeue / src / main / java / org / iotivity / cloud / mqserver / kafka / KafkaProducerWrapper.java
index 9feefeb..cf9d7d8 100644 (file)
@@ -26,10 +26,17 @@ import java.util.Properties;
 import org.apache.kafka.clients.producer.KafkaProducer;
 import org.apache.kafka.clients.producer.Producer;
 import org.apache.kafka.clients.producer.ProducerRecord;
-import org.iotivity.cloud.util.Logger;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * This class provides a set of APIs to use Kafka producer APIs for publishing
+ * messages.
+ *
+ */
 public class KafkaProducerWrapper {
-
+    private final static Logger      Log        = LoggerFactory.getLogger(KafkaProducerWrapper.class);
     private String                   mTopicName = null;
     private String                   mBroker    = null;
 
@@ -44,10 +51,18 @@ public class KafkaProducerWrapper {
         mProducer = new KafkaProducer<>(buildPropertiesForPublish());
     }
 
-    // TODO handle exception
+    /**
+     * API to publish message to Kafka topic
+     * 
+     * @param message
+     *            message to publish
+     * 
+     * @return returns true if the message is successfully published, otherwise
+     *         false
+     */
     public boolean publishMessage(byte[] message) {
 
-        Logger.d("kafka publishMessage - " + mTopicName);
+        Log.debug("kafka publishMessage - " + mTopicName);
 
         ProducerRecord<byte[], byte[]> record = new ProducerRecord<>(
                 mTopicName, message);
@@ -58,6 +73,9 @@ public class KafkaProducerWrapper {
         return true;
     }
 
+    /**
+     * API to close Kafka producer connection
+     */
     public void closeConnection() {
 
         mProducer.close();