Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-37921 Fixed subscription issue in migrated resident service. #1365

Merged
merged 13 commits into from
Dec 2, 2024
4 changes: 2 additions & 2 deletions resident/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<name>resident</name>
<description>Parent project of MOSIP Resident</description>
<url>https://github.com/mosip/resident-services</url>

<licenses>
<license>
<name>MPL 2.0</name>
Expand Down Expand Up @@ -79,6 +78,7 @@
**/constant/**,**/config/**,**/httpfilter/**,**/cache/**,**/dto/**,**/entity/**,**/model/**,**/exception/**,**/repository/**,**/security/**,**/*Config.java,**/*BootApplication.java,**/*VertxApplication.java,**/cbeffutil/**,**/mock/**,**/OrderCard*,**/testrig/**
</sonar.coverage.exclusions>
<sonar.cpd.exclusions>**/dto/**,**/entity/**,**/config/**</sonar.cpd.exclusions>
<kernel-bom.version>1.3.0-SNAPSHOT</kernel-bom.version>
</properties>

<modules>
Expand All @@ -89,7 +89,7 @@
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-bom</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>${kernel-bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
33 changes: 18 additions & 15 deletions resident/resident-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@
<name>resident-service</name>
<version>1.2.1-SNAPSHOT</version>
<properties>
<commons.packet.manager.version>1.2.1-SNAPSHOT</commons.packet.manager.version>
<kernel.core.version>1.2.1-SNAPSHOT</kernel.core.version>
<kernel.virusscanner.clamav.version>1.2.1-SNAPSHOT</kernel.virusscanner.clamav.version>
<kernel-keymanager-service.version>1.2.1-SNAPSHOT</kernel-keymanager-service.version>
<kernel.authcodeflowproxy.api.version>1.2.1-SNAPSHOT</kernel.authcodeflowproxy.api.version>
<kernel.parent.version>1.2.1-SNAPSHOT</kernel.parent.version>
<commons.packet.manager.version>1.3.0-SNAPSHOT</commons.packet.manager.version>
<kernel.core.version>1.3.0-SNAPSHOT</kernel.core.version>
<kernel.virusscanner.clamav.version>1.3.0-SNAPSHOT</kernel.virusscanner.clamav.version>
<kernel-keymanager-service.version>1.3.0-SNAPSHOT</kernel-keymanager-service.version>
<kernel.authcodeflowproxy.api.version>1.3.0-SNAPSHOT</kernel.authcodeflowproxy.api.version>
<kernel.parent.version>1.3.0-SNAPSHOT</kernel.parent.version>
<kernel-cbeffutil-api.version>${kernel.parent.version}</kernel-cbeffutil-api.version>
<kernel.khazana.version>1.2.1-SNAPSHOT</kernel.khazana.version>
<kernel-openid-bridge-api.version>1.2.1-SNAPSHOT</kernel-openid-bridge-api.version>
<kernel.khazana.version>1.3.0-SNAPSHOT</kernel.khazana.version>
<kernel-openid-bridge-api.version>1.3.0-SNAPSHOT</kernel-openid-bridge-api.version>
<maven.jacoco.plugin.version>0.8.11</maven.jacoco.plugin.version>
<kernel.idobjectvalidator.version>1.2.1-SNAPSHOT</kernel.idobjectvalidator.version>
<pre-registration-application-service.version>1.2.1-SNAPSHOT</pre-registration-application-service.version>
<kernel.idobjectvalidator.version>1.3.0-SNAPSHOT</kernel.idobjectvalidator.version>
<pre-registration-application-service.version>1.3.0-SNAPSHOT</pre-registration-application-service.version>
<jacoco.maven.plugin.version>0.8.11</jacoco.maven.plugin.version>
<id-repository-core.version>1.2.1-SNAPSHOT</id-repository-core.version>

<kernel-websubclient-api.version>1.3.0-SNAPSHOT</kernel-websubclient-api.version>
<kernel-pdfgenerator-itext.version>1.3.0-SNAPSHOT</kernel-pdfgenerator-itext.version>
<kernel-ref-idobjectvalidato.version>1.3.0-SNAPSHOT</kernel-ref-idobjectvalidato.version>
<kernel-auth-adpater.version>1.3.0-SNAPSHOT</kernel-auth-adpater.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -254,7 +257,7 @@
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-websubclient-api</artifactId>
<version>${project.version}</version>
<version>${kernel-websubclient-api.version}</version>
</dependency>
<dependency>
<groupId>org.mvel</groupId>
Expand Down Expand Up @@ -299,7 +302,7 @@
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-pdfgenerator-itext</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>${kernel-pdfgenerator-itext.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
Expand All @@ -319,12 +322,12 @@
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-auth-adapter</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>${kernel-auth-adpater.version}</version>
</dependency>
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-ref-idobjectvalidator</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>${kernel-ref-idobjectvalidato.version}</version>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -49,6 +51,7 @@
@Configuration
@EnableScheduling
@EnableAsync
@Import(WebSubClientConfig.class)
public class Config {
private String defaultEncoding = StandardCharsets.UTF_8.name();
/** The resource loader. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

import java.io.IOException;

/**
@author Kamesh Shekhar Prasad
*/

@Component
public class TrailingSlashRedirectFilter implements Filter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,32 +89,53 @@ public class BaseWebSubInitializer implements ApplicationListener<ApplicationRea

@Value("${resident.websub.regproc.workflow.complete.secret}")
private String regProcWorkFlowCompleteSecret;



@Value("${task.scheduler.pool-size:10}")
private int poolSize;

@Value("${task.scheduler.thread-name-prefix:TaskScheduler-}")
private String threadNamePrefix;

@Value("${task.scheduler.await-termination-seconds:30}")
private int awaitTerminationSeconds;

@Value("${task.scheduler.wait-for-tasks-to-complete-on-shutdown:true}")
private boolean waitForTasksToCompleteOnShutdown;

@Override
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
logger.info("onApplicationEvent", "BaseWebSubInitializer", "Application is ready");
logger.info("Scheduling event subscriptions after (milliseconds): " + taskSubscriptionInitialDelay);
logger.info("Scheduling event subscriptions after (milliseconds): " + taskSubscriptionInitialDelay);
taskScheduler.setPoolSize(poolSize);
taskScheduler.setThreadNamePrefix(threadNamePrefix);
taskScheduler.setWaitForTasksToCompleteOnShutdown(waitForTasksToCompleteOnShutdown);
taskScheduler.setAwaitTerminationSeconds(awaitTerminationSeconds);

taskScheduler.schedule(() -> {
//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();
Expand Down