topic: ${CPS_CHANGE_EVENT_TOPIC:cps.data-updated-events}\r
filters:\r
enabled-dataspaces: ${NOTIFICATION_DATASPACE_FILTER_PATTERNS:""}\r
- async-executor:\r
- core-pool-size: 2\r
- max-pool-size: 10\r
- queue-capacity: 500\r
- wait-for-tasks-to-complete-on-shutdown: true\r
- thread-name-prefix: Async-\r
+ async:\r
+ enabled: false\r
+ executor:\r
+ core-pool-size: 2\r
+ max-pool-size: 10\r
+ queue-capacity: 500\r
+ wait-for-tasks-to-complete-on-shutdown: true\r
+ thread-name-prefix: Async-\r
\r
\r
springdoc:\r
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;
@EnableAsync
@Configuration
-@ConfigurationProperties("notification.async-executor")
+@ConditionalOnProperty(name = "notification.async.enabled", havingValue = "true", matchIfMissing = false)
+@ConfigurationProperties("notification.async.executor")
@Validated
@Setter
public class AsyncConfig {
import java.util.concurrent.TimeUnit
@SpringBootTest
-@EnableAsync
@EnableConfigurationProperties
@ContextConfiguration(classes = [NotificationProperties, NotificationService, NotificationErrorHandler, AsyncConfig])
class NotificationServiceSpec extends Specification {
1 * spyNotificationErrorHandler.onException(_, _, _, _)
}
- NotificationService createNotificationService(boolean notificationEnabled) {
- spyNotificationProperties = Spy(notificationProperties)
- spyNotificationProperties.isEnabled() >> notificationEnabled
- return new NotificationService(spyNotificationProperties, mockNotificationPublisher,
- mockCpsDataUpdatedEventFactory, spyNotificationErrorHandler)
- }
}
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: