package org.acme.rest.json;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.core.UriBuilder;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
public class ArticlesDataAccess {
private static final int MAXIMAL_DURATION = 5000;
// this configuration needs to be used when running the code in OpenShift
private static String urlArticlesServiceLocal = "http://articles-reactive:8080/v2/articles?amount=10";
private ArticlesService articlesService;
URI apiUrl = UriBuilder.fromUri(urlArticlesServiceLocal).build();
articlesService = RestClientBuilder.newBuilder()
.register(ExceptionMapperArticles.class)
.build(ArticlesService.class);
public CompletionStage<List<Article>> getArticlesReactive(int amount) {
return articlesService.getArticlesFromService(amount);