Skip to content
Snippets Groups Projects
Commit 410df8dd authored by Alok Joshi's avatar Alok Joshi
Browse files

Merge branch 'vl/not-found-subs' into 'master'

Add cache for not found subscription

See merge request !551
parents 85475e78 75098f3a
No related branches found
No related tags found
1 merge request!551Add cache for not found subscription
Pipeline #305338 failed
......@@ -36,6 +36,8 @@ import java.util.List;
@Component
public class SubscriptionHandler {
private static final String STATUS_NOT_FOUND = "not-found";
@Autowired
private ISubscriptionFactory subscriptionFactory;
@Autowired
......@@ -51,8 +53,12 @@ public class SubscriptionHandler {
public Subscription getSubscriptionFromCache(String notificationId) throws IOException, SubscriptionException {
String subscriptionString = subscriptionCacheFactory.get(notificationId);
try {
if (Strings.isNullOrEmpty(subscriptionString))
if (Strings.isNullOrEmpty(subscriptionString)) {
subscriptionString = querySubscriptionAndUpdateCache(notificationId);
}
if (subscriptionString.equals(STATUS_NOT_FOUND)) {
throw new AppException(HttpStatus.SC_NOT_FOUND, "Unable to find a subscription with notificationId:" + notificationId, "Subscription not found");
}
ObjectMapper objectMapper = this.getObjectMapper();
Subscription subscription = objectMapper.readValue(subscriptionString, Subscription.class);
return subscription;
......@@ -68,7 +74,8 @@ public class SubscriptionHandler {
List<Subscription> subscriptionList = service.query(notificationId);
if (subscriptionList == null || subscriptionList.size() == 0) {
throw new AppException(HttpStatus.SC_NOT_FOUND, "Not found subscription for notificationId:" + notificationId, "Subscription not found");
this.subscriptionCacheFactory.put(notificationId, STATUS_NOT_FOUND);
return STATUS_NOT_FOUND;
}
Subscription subscription = subscriptionList.get(0);
......
......@@ -35,8 +35,8 @@ PARTITION_API=${partition_service_endpoint}
app.entitlements=${entitlements_service_endpoint}
app.register=${registeration_service_endpoint}
app.project=opendes
app.expireTime=300
app.maxCacheSize=10
app.expireTime=600
app.maxCacheSize=100
# Azure AD configuration
#azure.activedirectory.client-id=${aad_client_id}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment