Skip to content

Instantly share code, notes, and snippets.

@danielbryantuk
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielbryantuk/9c8a3fbe9c04243b2e76 to your computer and use it in GitHub Desktop.
Save danielbryantuk/9c8a3fbe9c04243b2e76 to your computer and use it in GitHub Desktop.
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