Last active
September 3, 2021 15:07
-
-
Save danielkec/8f19a6fa8b3aa2ee232cf0a211fb2f09 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
@Path("/example") | |
@ApplicationScoped | |
public class LRAExampleResource { | |
@PUT | |
@LRA(value = LRA.Type.REQUIRES_NEW, timeLimit = 500, timeUnit = ChronoUnit.MILLIS) | |
@Path("start-example") | |
public Response startExample(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId, String data){ | |
// Executed in the scope of new LRA transaction | |
return Response.ok().build(); | |
} | |
@PUT | |
@Complete | |
@Path("complete-example") | |
public Response completeExample(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId) { | |
// Called by LRA coordinator when startExample method sucessfully finishes | |
return LRAResponse.completed(); | |
} | |
@PUT | |
@Compensate | |
@Path("compensate-example") | |
public Response compensateExample(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId) { | |
// Called by LRA coordinator when startExample method throws exception or don't finish before time limit | |
return LRAResponse.compensated(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment