Last active
August 29, 2015 14:01
-
-
Save danielbryantuk/9c8a3fbe9c04243b2e76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CorrelationCallable<V> implements Callable<V> { | |
private String correlationId; | |
private Callable<V> callable; | |
public CorrelationCallable(Callable<V> targetCallable) { | |
correlationId = RequestCorrelation.getId(); | |
callable = targetCallable; | |
} | |
@Override | |
public V call() throws Exception { | |
RequestCorrelation.setId(correlationId); | |
return callable.call(); | |
} | |
} | |
//... Calling Class | |
@RequestMapping("externalNews") | |
public DeferredResult<String> externalNews() { | |
return new ListenableFutureAdapter<>(service.submit(new CorrelationCallable<>(externalNewsService::getNews))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment