Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.quarkus.ts.http.restclient.reactive.fault.tolerance;

import org.eclipse.microprofile.faulttolerance.Retry;

@Retry(maxRetries = 2)
public abstract class AbstractFaultToleranceService {
public abstract String performAction();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.quarkus.ts.http.restclient.reactive.fault.tolerance;

import java.util.concurrent.atomic.AtomicInteger;

import jakarta.enterprise.context.ApplicationScoped;

@ApplicationScoped
public class SpecificRetryService extends AbstractFaultToleranceService {
private final AtomicInteger atomicInteger = new AtomicInteger(0);

@Override
public String performAction() {
final int count = atomicInteger.getAndIncrement();
if (count < 1) {
throw new RuntimeException("Failure on attempt " + count);
}
return "OK";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkus.ts.http.restclient.reactive.resources;

import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import io.quarkus.ts.http.restclient.reactive.fault.tolerance.SpecificRetryService;

@Path("/ft-reflection")
public class FaultToleranceReflectionResource {

@Inject
SpecificRetryService specificRetryService;

@GET
@Produces(MediaType.TEXT_PLAIN)
public Response response() {
String result = specificRetryService.performAction();
return Response.ok(result).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.quarkus.ts.http.restclient.reactive;

import static org.hamcrest.Matchers.is;

import org.apache.http.HttpStatus;
import org.junit.jupiter.api.Test;

import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.QuarkusScenario;
import io.quarkus.test.services.QuarkusApplication;

@QuarkusScenario
public class ReflectionRegisterFaultToleranceIT {

@QuarkusApplication
static RestService app = new RestService();

@Test
void testRegisterAnnotationWorksWithReflection() {
app.given().get("/ft-reflection")
.then()
.statusCode(HttpStatus.SC_OK)
.body(is("OK"));
}
}