summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenu Kumari <renu.kumari@bell.ca>2021-09-02 10:30:09 -0400
committerRenu Kumari <renu.kumari@bell.ca>2021-09-02 11:44:57 -0400
commitcd048075b11eef88501619da0068d5eb6dd330f7 (patch)
tree92f4feaad6d0d92170eb4d1949686972e5840966
parent88cadd3f3aaa22cccb0d2159cf57fb2b84d440a2 (diff)
Add property to enable Notification Sevice async processing
- made notification service synchronous by default - added new property to enable async processing if required Issue-ID: CPS-630 Signed-off-by: Renu Kumari <renu.kumari@bell.ca> Change-Id: I28c2c98d7a79219a5932732d2940f5ac37bf1653
-rw-r--r--cps-application/src/main/resources/application.yml14
-rw-r--r--cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java4
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy7
-rw-r--r--cps-service/src/test/resources/application.yml10
4 files changed, 17 insertions, 18 deletions
diff --git a/cps-application/src/main/resources/application.yml b/cps-application/src/main/resources/application.yml
index 82c6e0aed1..42addf1b0c 100644
--- a/cps-application/src/main/resources/application.yml
+++ b/cps-application/src/main/resources/application.yml
@@ -74,12 +74,14 @@ notification:
topic: ${CPS_CHANGE_EVENT_TOPIC:cps.data-updated-events}
filters:
enabled-dataspaces: ${NOTIFICATION_DATASPACE_FILTER_PATTERNS:""}
- async-executor:
- core-pool-size: 2
- max-pool-size: 10
- queue-capacity: 500
- wait-for-tasks-to-complete-on-shutdown: true
- thread-name-prefix: Async-
+ async:
+ enabled: false
+ executor:
+ core-pool-size: 2
+ max-pool-size: 10
+ queue-capacity: 500
+ wait-for-tasks-to-complete-on-shutdown: true
+ thread-name-prefix: Async-
springdoc:
diff --git a/cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java b/cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java
index 4c961598e4..2667ef4909 100644
--- a/cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java
+++ b/cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java
@@ -22,6 +22,7 @@ package org.onap.cps.config;
import javax.validation.constraints.Min;
import lombok.Setter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -32,7 +33,8 @@ import org.springframework.validation.annotation.Validated;
@EnableAsync
@Configuration
-@ConfigurationProperties("notification.async-executor")
+@ConditionalOnProperty(name = "notification.async.enabled", havingValue = "true", matchIfMissing = false)
+@ConfigurationProperties("notification.async.executor")
@Validated
@Setter
public class AsyncConfig {
diff --git a/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy
index 875113d225..ca704edb4c 100644
--- a/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy
@@ -36,7 +36,6 @@ import spock.lang.Specification
import java.util.concurrent.TimeUnit
@SpringBootTest
-@EnableAsync
@EnableConfigurationProperties
@ContextConfiguration(classes = [NotificationProperties, NotificationService, NotificationErrorHandler, AsyncConfig])
class NotificationServiceSpec extends Specification {
@@ -105,10 +104,4 @@ class NotificationServiceSpec extends Specification {
1 * spyNotificationErrorHandler.onException(_, _, _, _)
}
- NotificationService createNotificationService(boolean notificationEnabled) {
- spyNotificationProperties = Spy(notificationProperties)
- spyNotificationProperties.isEnabled() >> notificationEnabled
- return new NotificationService(spyNotificationProperties, mockNotificationPublisher,
- mockCpsDataUpdatedEventFactory, spyNotificationErrorHandler)
- }
}
diff --git a/cps-service/src/test/resources/application.yml b/cps-service/src/test/resources/application.yml
index b1546d74f3..436c3d4c34 100644
--- a/cps-service/src/test/resources/application.yml
+++ b/cps-service/src/test/resources/application.yml
@@ -22,10 +22,12 @@ notification:
enabled-dataspaces: ".*-published,.*-important"
enabled: true
topic: cps-event
- async-executor:
- core-pool-size: 2
- max-pool-size: 10
- queue-capacity: 0
+ async:
+ enabled: true
+ executor:
+ core-pool-size: 2
+ max-pool-size: 10
+ queue-capacity: 0
spring:
kafka: