Skip to content

Instantly share code, notes, and snippets.

@danielkec
Last active September 3, 2021 15:07
Show Gist options
  • Save danielkec/8f19a6fa8b3aa2ee232cf0a211fb2f09 to your computer and use it in GitHub Desktop.
Save danielkec/8f19a6fa8b3aa2ee232cf0a211fb2f09 to your computer and use it in GitHub Desktop.
@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