Class PaymentResource
java.lang.Object
io.github.ravocode.avoonce.sample.quarkus.PaymentResource
@Path("/api/payments")
@ApplicationScoped
@Produces("application/json")
public class PaymentResource
extends Object
Sample JAX-RS resource in Quarkus demonstrating selective idempotency
protection using the
Idempotent name-binding annotation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classResponse payload used for the process-count endpoint.static classIncoming payment request payload used by the Quarkus resource.static classResponse payload returned after processing a payment request. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjakarta.ws.rs.core.ResponseReturns the current number of processed payment requests.jakarta.ws.rs.core.ResponseProtected endpoint: annotated withIdempotent.jakarta.ws.rs.core.ResponseUnprotected endpoint: NOT annotated withIdempotent.jakarta.ws.rs.core.ResponseResets the sample resource's processing counter.
-
Constructor Details
-
PaymentResource
public PaymentResource()
-
-
Method Details
-
processPayment
@POST @Consumes("application/json") public jakarta.ws.rs.core.Response processPayment(PaymentResource.PaymentRequest request) Protected endpoint: annotated withIdempotent. Requests with an Idempotency-Key header are deduplicated, locked, and cached.- Parameters:
request- the payment request payload- Returns:
- a response containing the processing outcome
-
processUnprotectedPayment
@POST @Path("/unprotected") @Consumes("application/json") public jakarta.ws.rs.core.Response processUnprotectedPayment(PaymentResource.PaymentRequest request) Unprotected endpoint: NOT annotated withIdempotent. Even if an Idempotency-Key header is provided, this endpoint is NOT intercepted by the filter.- Parameters:
request- the payment request payload- Returns:
- a response containing the processing outcome
-
getProcessCount
@GET @Path("/count") public jakarta.ws.rs.core.Response getProcessCount()Returns the current number of processed payment requests.- Returns:
- a response containing the process count
-
resetCount
@POST @Path("/reset") public jakarta.ws.rs.core.Response resetCount()Resets the sample resource's processing counter.- Returns:
- an empty success response
-