summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service')
-rw-r--r--cps-ncmp-service/pom.xml2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsService.java7
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsServiceSpec.groovy14
3 files changed, 21 insertions, 2 deletions
diff --git a/cps-ncmp-service/pom.xml b/cps-ncmp-service/pom.xml
index 0e192bd8a..6a9d9485c 100644
--- a/cps-ncmp-service/pom.xml
+++ b/cps-ncmp-service/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.1.1-SNAPSHOT</version>
+ <version>3.1.5-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsService.java
index 762b21ef3..d6857d36a 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsService.java
@@ -24,6 +24,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.ncmp.cmhandle.event.lcm.LcmEvent;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.kafka.KafkaException;
import org.springframework.stereotype.Service;
/**
@@ -51,7 +52,11 @@ public class LcmEventsService {
*/
public void publishLcmEvent(final String cmHandleId, final LcmEvent lcmEvent) {
if (notificationsEnabled) {
- lcmEventsPublisher.publishEvent(topicName, cmHandleId, lcmEvent);
+ try {
+ lcmEventsPublisher.publishEvent(topicName, cmHandleId, lcmEvent);
+ } catch (final KafkaException e) {
+ log.error("Unable to publish message to topic : {} and cause : {}", topicName, e.getMessage());
+ }
} else {
log.debug("Notifications disabled.");
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsServiceSpec.groovy
index 1eae357bb..ef399e1c6 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsServiceSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsServiceSpec.groovy
@@ -21,6 +21,7 @@
package org.onap.cps.ncmp.api.impl.event.lcm
import org.onap.ncmp.cmhandle.event.lcm.LcmEvent
+import org.springframework.kafka.KafkaException
import spock.lang.Specification
class LcmEventsServiceSpec extends Specification {
@@ -45,4 +46,17 @@ class LcmEventsServiceSpec extends Specification {
'disabled' | false || 0
}
+ def 'Unable to send message'(){
+ given: 'a cm handle id and Lcm Event and notification enabled'
+ def cmHandleId = 'test-cm-handle-id'
+ def lcmEvent = new LcmEvent(eventId: UUID.randomUUID().toString(), eventCorrelationId: cmHandleId)
+ objectUnderTest.notificationsEnabled = true
+ when: 'publisher set to throw an exception'
+ mockLcmEventsPublisher.publishEvent(*_) >> { throw new KafkaException('publishing failed')}
+ and: 'an event is publised'
+ objectUnderTest.publishLcmEvent(cmHandleId, lcmEvent)
+ then: 'the exception is just logged and not bubbled up'
+ noExceptionThrown()
+ }
+
}