Skip to content

Instantly share code, notes, and snippets.

@paulparkinson
Last active September 14, 2019 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulparkinson/9518d1b71c7d8c97fc529bc02d668f0a to your computer and use it in GitHub Desktop.
Save paulparkinson/9518d1b71c7d8c97fc529bc02d668f0a to your computer and use it in GitHub Desktop.
LRA participant: inventory service
@Path("/reserveInventoryForOrder")
@GET
@Produces(MediaType.APPLICATION_JSON)
@LRA(value = LRA.Type.MANDATORY, end = false)
public Response reserveInventoryForOrder(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) String lraId) {
//...
if(inventoryExists) return Response.ok().entity("inventorysuccess").build();
else return Response.ok().entity("inventoryfailure").build();
}
@Path("/completeOrder")
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Complete
public Response completeOrder(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) String lraId) throws NotFoundException {
//...
}
@Path("/cancelOrder")
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Compensate
public Response cancelOrder(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) String lraId) throws NotFoundException {
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment