diff --git a/resident/pom.xml b/resident/pom.xml index 5c26cf285eb..f9bf7722644 100644 --- a/resident/pom.xml +++ b/resident/pom.xml @@ -11,7 +11,6 @@ resident Parent project of MOSIP Resident https://github.com/mosip/resident-services - MPL 2.0 @@ -79,6 +78,7 @@ **/constant/**,**/config/**,**/httpfilter/**,**/cache/**,**/dto/**,**/entity/**,**/model/**,**/exception/**,**/repository/**,**/security/**,**/*Config.java,**/*BootApplication.java,**/*VertxApplication.java,**/cbeffutil/**,**/mock/**,**/OrderCard*,**/testrig/** **/dto/**,**/entity/**,**/config/** + 1.3.0-SNAPSHOT @@ -89,7 +89,7 @@ io.mosip.kernel kernel-bom - 1.2.1-SNAPSHOT + ${kernel-bom.version} pom import diff --git a/resident/resident-service/pom.xml b/resident/resident-service/pom.xml index a5b16e42b95..bf1e46137b0 100644 --- a/resident/resident-service/pom.xml +++ b/resident/resident-service/pom.xml @@ -13,21 +13,24 @@ resident-service 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT + 1.3.0-SNAPSHOT + 1.3.0-SNAPSHOT + 1.3.0-SNAPSHOT + 1.3.0-SNAPSHOT + 1.3.0-SNAPSHOT + 1.3.0-SNAPSHOT ${kernel.parent.version} - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT + 1.3.0-SNAPSHOT + 1.3.0-SNAPSHOT 0.8.11 - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT + 1.3.0-SNAPSHOT + 1.3.0-SNAPSHOT 0.8.11 1.2.1-SNAPSHOT - + 1.3.0-SNAPSHOT + 1.3.0-SNAPSHOT + 1.3.0-SNAPSHOT + 1.3.0-SNAPSHOT @@ -254,7 +257,7 @@ io.mosip.kernel kernel-websubclient-api - ${project.version} + ${kernel-websubclient-api.version} org.mvel @@ -299,7 +302,7 @@ io.mosip.kernel kernel-pdfgenerator-itext - 1.2.1-SNAPSHOT + ${kernel-pdfgenerator-itext.version} org.springframework.security @@ -319,12 +322,12 @@ io.mosip.kernel kernel-auth-adapter - 1.2.1-SNAPSHOT + ${kernel-auth-adpater.version} io.mosip.kernel kernel-ref-idobjectvalidator - 1.2.1-SNAPSHOT + ${kernel-ref-idobjectvalidato.version} diff --git a/resident/resident-service/src/main/java/io/mosip/resident/ResidentBootApplication.java b/resident/resident-service/src/main/java/io/mosip/resident/ResidentBootApplication.java index 91da7352bb0..54f4dfa67d8 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/ResidentBootApplication.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/ResidentBootApplication.java @@ -8,9 +8,9 @@ import io.mosip.kernel.pdfgenerator.itext.impl.PDFGeneratorImpl; import io.mosip.kernel.templatemanager.velocity.builder.TemplateManagerBuilderImpl; import io.mosip.kernel.transliteration.icu4j.impl.TransliterationImpl; -import io.mosip.kernel.websub.api.client.PublisherClientImpl; -import io.mosip.kernel.websub.api.client.SubscriberClientImpl; +import io.mosip.kernel.websub.api.config.WebSubClientConfig; import io.mosip.kernel.websub.api.config.publisher.RestTemplateHelper; +import io.mosip.kernel.websub.api.config.publisher.WebSubPublisherClientConfig; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -37,14 +37,16 @@ "io.mosip.kernel.virusscanner.*", "io.mosip.commons.khazana.*", "io.mosip.idrepository.core.util.*", - "io.mosip.kernel.authcodeflowproxy.*"} + "io.mosip.kernel.authcodeflowproxy.*", + "io.mosip.kernel.websub.api.config"} ) @EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, HibernateJpaAutoConfiguration.class }) @Import({TokenIDGenerator.class, ValidateTokenUtil.class, CbeffImpl.class, TransliterationService.class, TransliterationServiceUtil.class , PDFGeneratorImpl.class, UinValidatorImpl.class, VidValidatorImpl.class, RidValidatorImpl.class, TemplateManagerBuilderImpl.class, - SubscriberClientImpl.class, RestTemplateHelper.class, TransliterationImpl.class, PublisherClientImpl.class, IdObjectValidatorConfig.class - , RestTemplate.class, KeyStoreImpl.class}) + RestTemplateHelper.class, TransliterationImpl.class, IdObjectValidatorConfig.class + , RestTemplate.class, KeyStoreImpl.class, WebSubPublisherClientConfig.class, + WebSubClientConfig.class,}) public class ResidentBootApplication { public static void main(String[] args) { diff --git a/resident/resident-service/src/main/java/io/mosip/resident/config/Config.java b/resident/resident-service/src/main/java/io/mosip/resident/config/Config.java index 08de612bc72..840614330c7 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/config/Config.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/config/Config.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Properties; +import io.mosip.kernel.websub.api.config.WebSubClientConfig; import jakarta.servlet.Filter; import org.apache.commons.collections.CollectionUtils; @@ -22,6 +23,7 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Primary; import org.springframework.core.env.Environment; import org.springframework.core.io.Resource; @@ -49,6 +51,7 @@ @Configuration @EnableScheduling @EnableAsync +@Import(WebSubClientConfig.class) public class Config { private String defaultEncoding = StandardCharsets.UTF_8.name(); /** The resource loader. */ @@ -68,7 +71,15 @@ public class Config { @Value("${" + ResidentConstants.RESIDENT_REST_TEMPLATE_METRICS_INTERCEPTOR_FILTER_ENABLED + ":false}") private boolean isResidentMetricsInterceptorFilterEnabled; - + + @Value("${task.scheduler.pool-size:10}") + private int poolSize; + + @Value("${task.scheduler.await-termination-seconds:30}") + private int awaitTerminationSeconds; + + @Value("${task.scheduler.wait-for-tasks-to-complete-on-shutdown:true}") + private boolean waitForTasksToCompleteOnShutdown; @Autowired(required = false) private RestTemplateLoggingInterceptor restTemplateLoggingInterceptor; @@ -172,8 +183,10 @@ private void addInterceptors(RestTemplate restTemplate) { @Bean public ThreadPoolTaskScheduler threadPoolTaskScheduler() { ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler(); - threadPoolTaskScheduler.setPoolSize(5); + threadPoolTaskScheduler.setPoolSize(poolSize); threadPoolTaskScheduler.setThreadNamePrefix("ThreadPoolTaskScheduler"); + threadPoolTaskScheduler.setWaitForTasksToCompleteOnShutdown(waitForTasksToCompleteOnShutdown); + threadPoolTaskScheduler.setAwaitTerminationSeconds(awaitTerminationSeconds); return threadPoolTaskScheduler; } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/config/TrailingSlashRedirectFilter.java b/resident/resident-service/src/main/java/io/mosip/resident/config/TrailingSlashRedirectFilter.java index c283efa0871..5005486fceb 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/config/TrailingSlashRedirectFilter.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/config/TrailingSlashRedirectFilter.java @@ -7,6 +7,10 @@ import java.io.IOException; +/** +@author Kamesh Shekhar Prasad + */ + @Component public class TrailingSlashRedirectFilter implements Filter { @@ -16,9 +20,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha HttpServletRequest httpRequest = (HttpServletRequest) request; String path = httpRequest.getRequestURI(); - - // For other types of requests, handle the trailing slash redirection - if (path.endsWith("/")) { + if (path.endsWith("/") && !path.endsWith("status/")) { String newPath = path.substring(0, path.length() - 1); HttpServletRequest newRequest = new CustomHttpServletRequestWrapper(httpRequest, newPath); chain.doFilter(newRequest, response); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/BaseWebSubInitializer.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/BaseWebSubInitializer.java index 95466acf646..ab09bcbad0f 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/BaseWebSubInitializer.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/BaseWebSubInitializer.java @@ -89,32 +89,53 @@ public class BaseWebSubInitializer implements ApplicationListener { - //Invoke topic registrations. This is done only once. - //Note: With authenticated websub, only register topics which are only published by IDA - tryRegisteringTopics(); - //Init topic subscriptions - initTopicSubscriptions(); - }, new Date(System.currentTimeMillis() + taskSubscriptionInitialDelay)); - - if (reSubscriptionIntervalSecs > 0) { - logger.info("Work around for web-sub notification issue after some time."); - scheduleRetrySubscriptions(); - } else { - logger.info("Scheduling for re-subscription is Disabled as the re-subsctription delay value is: " - + reSubscriptionIntervalSecs); - } + try { + // Invoke topic registrations (done only once) + tryRegisteringTopics(); + // Initialize topic subscriptions + initTopicSubscriptions(); + } catch (Exception e) { + logger.error("Error while scheduling topic registrations and subscriptions", e); + } + }, trigger -> { + // Schedule task to execute once after the initial delay + return new Date(System.currentTimeMillis() + taskSubscriptionInitialDelay).toInstant(); + }); + if (reSubscriptionIntervalSecs > 0) { + logger.info("Workaround for web-sub notification issue after some time."); + scheduleRetrySubscriptions(); + } else { + logger.info("Re-subscription scheduling is disabled as the re-subscription interval is: " + + reSubscriptionIntervalSecs); + } } - private void initTopicSubscriptions() { + + private void initTopicSubscriptions() { authTypStatusTopicSubsriptions(); authTransactionTopicSubscription(); credentialStatusUpdateTopicSubscription(); diff --git a/resident/resident-service/src/main/resources/bootstrap.properties b/resident/resident-service/src/main/resources/bootstrap.properties index cc6f20acce1..bae5a4b58aa 100644 --- a/resident/resident-service/src/main/resources/bootstrap.properties +++ b/resident/resident-service/src/main/resources/bootstrap.properties @@ -32,3 +32,5 @@ mosipbox.public.url=http://localhost:8099 openapi.residentServiceServer.servers[0].url=${mosipbox.public.url}/resident/v1 openapi.residentServiceServer.servers[0].description=Resident Service spring.devtools.restart.enabled = false + +logging.level.root=DEBUG \ No newline at end of file