Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
Hi, i am using spring boot 1.5 and hystrix (spring-cloud-starter-hystrix).
I am using semaphore isolation strategy, but still in the fallback method, Authentication is not available in the SecurityContext. However, according to the documentation, SecurityContext will be maintained with SEMAPHORE isolation.
What should be done to fix this? Here is what i have tried :
@CachePut(cacheNames = Constants.CACHE_NAME_ALL_COLLIBRA_ASSETS_BY_DOMAIN_ID_BACKUP, key = "#domainId")
@HystrixCommand(fallbackMethod = "getAssetsFromBackup", commandKey = "getMetadataAssets", commandProperties = {
@HystrixProperty(name = "execution.isolation.strategy", value = "SEMAPHORE")
})
public String getAssetsByDomain(String domainId) {
String assets = null;
try {
Map<String, Object> queryParams = new HashMap<>();
queryParams.put("domainId", domainId);
queryParams.put("limit", Constants.COLLIBRA_GET_ALL_ASSETS_LIMIT);
queryParams.put("offset", Constants.COLLIBRA_GET_ALL_ASSETS_OFFSET);
ResponseEntity<String> response = collibraProxy.callCollibra(GET_ALL_ASSETS_ENDPOINT, HttpMethod.GET, null, queryParams);
if (response.getStatusCode() == HttpStatus.OK) {
assets = response.getBody();
} else {
throw new FGCollibException("Exception while getting OK response from Collibra: " + response.getStatusCode());
}
} catch (FGCollibException e) {
logger.error("Error in getting assets from collibra for domainId {}", domainId, e);
throw new FgException("Error getting response from collibra");
}
return assets;
}
public String getAssetsFromBackup(String domainId) {
try {
logger.info("Executing fallback logic for collibra backup");
CacheEntry entry = cacheService.get(Constants.CACHE_NAME_ALL_COLLIBRA_ASSETS_BY_DOMAIN_ID_BACKUP, domainId);
if (entry != null) {
return (String) entry.getV();
}
} catch (Exception e) {
logger.error("Error in getting assets from collibra backup for domainId {}", domainId, e);
}
return null;
}
The collibraProxy.callCollibra(GET_ALL_ASSETS_ENDPOINT, HttpMethod.GET, null, queryParams); call timeouts and the fallback method getAssetsFromBackup method is called. However, it looses the context.
Edit :
I have tried using custom concurrency strategy, this doesn't work either.
ConcurrencyStrategy:
Hi, i am using spring boot 1.5 and hystrix (spring-cloud-starter-hystrix). I am using semaphore isolation strategy, but still in the fallback method, Authentication is not available in the SecurityContext. However, according to the documentation, SecurityContext will be maintained with SEMAPHORE isolation. What should be done to fix this? Here is what i have tried :
The
collibraProxy.callCollibra(GET_ALL_ASSETS_ENDPOINT, HttpMethod.GET, null, queryParams);
call timeouts and the fallback methodgetAssetsFromBackup
method is called. However, it looses the context.Edit : I have tried using custom concurrency strategy, this doesn't work either. ConcurrencyStrategy:
Configuration:
The breakpoint does not hit
wrapCallable
, i assume the strategy is not registered?