Kafka consumer can not be turned off
[cps.git] / cps-ncmp-service / src / main / java / org / onap / cps / ncmp / api / impl / event / NcmpEventsService.java
index 6804ac0..7b5ceb5 100644 (file)
@@ -47,17 +47,23 @@ public class NcmpEventsService {
     @Value("${app.ncmp.events.topic:ncmp-events}")
     private String topicName;
 
+    @Value("${notification.enabled:true}")
+    private boolean notificationsEnabled;
+
     /**
      * Publish the NcmpEvent to the public topic.
      *
      * @param cmHandleId Cm Handle Id
      */
     public void publishNcmpEvent(final String cmHandleId) {
-
-        final NcmpServiceCmHandle ncmpServiceCmHandle = YangDataConverter.convertYangModelCmHandleToNcmpServiceCmHandle(
-                inventoryPersistence.getYangModelCmHandle(cmHandleId));
-        final NcmpEvent ncmpEvent = ncmpEventsCreator.populateNcmpEvent(cmHandleId, ncmpServiceCmHandle);
-        ncmpEventsPublisher.publishEvent(topicName, cmHandleId, ncmpEvent);
-
+        if (notificationsEnabled) {
+            final NcmpServiceCmHandle ncmpServiceCmHandle =
+                YangDataConverter.convertYangModelCmHandleToNcmpServiceCmHandle(
+                    inventoryPersistence.getYangModelCmHandle(cmHandleId));
+            final NcmpEvent ncmpEvent = ncmpEventsCreator.populateNcmpEvent(cmHandleId, ncmpServiceCmHandle);
+            ncmpEventsPublisher.publishEvent(topicName, cmHandleId, ncmpEvent);
+        } else {
+            log.debug("Notifications disabled.");
+        }
     }
 }