Skip to content

Commit

Permalink
Added config for subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
NagarjunaKuchi committed Feb 11, 2024
1 parent f84a277 commit 52c73fc
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mediator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@
<artifactId>httpclient</artifactId>
<version>${apache.httpcomponents.version}</version>
</dependency>
<dependency>
<!--<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>${apache.kafka.version}</version>
</dependency>
</dependency>-->

<dependency>
<groupId>io.micrometer</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.mosip.opencrvs.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import io.mosip.kernel.core.websub.spi.SubscriptionClient;
import io.mosip.kernel.websub.api.model.SubscriptionChangeRequest;
import io.mosip.kernel.websub.api.model.SubscriptionChangeResponse;
import io.mosip.kernel.websub.api.model.UnsubscriptionRequest;

@Configuration
public class SubscribeConfig {

@Autowired
protected SubscriptionClient<SubscriptionChangeRequest, UnsubscriptionRequest, SubscriptionChangeResponse> subscriptionClient;

@Value("${websub.hub.url}")
private String hubUrl;

@Value("${mosip.opencrvs.partner.client.sha.secret}")
private String callBackSecret;

@Value("${mosip.opencrvs.partner.client.id}")
private String topic;

@Value("${mosip.receive.credential.url}")
private String callbackUrl;

protected void subscribeForPartnerCertEvent() {
try {
System.out.println("Started subscribing.......");
SubscriptionChangeRequest subscriptionRequest = new SubscriptionChangeRequest();
subscriptionRequest.setCallbackURL(callbackUrl);
subscriptionRequest.setSecret(callBackSecret);
subscriptionRequest.setTopic(topic+ "/CREDENTIAL_ISSUED");
subscriptionRequest.setHubURL(hubUrl);
subscriptionClient.subscribe(subscriptionRequest);
System.out.println("Subscribing done.......... for event " + topic+ "/CREDENTIAL_ISSUED");
} catch (Exception e) {
System.out.println("Error while subscribing..........");
e.printStackTrace();
throw e;
}
}
}

0 comments on commit 52c73fc

Please sign in to comment.