Search in sources :

Example 11 with Activity

use of io.narayana.lra.participant.model.Activity in project narayana by jbosstm.

the class ActivityController method complete.

/**
 * Performing a PUT on <participant URL>/complete will cause the participant to tidy up and it can forget this transaction.
 *
 * The participant will either return a 200 OK code and a <status URL> which indicates the outcome and which can be probed (via GET)
 * and will simply return the same (implicit) information:
 * <URL>/cannot-compensate
 * <URL>/cannot-complete
 */
@PUT
@Path("/{TxId}/complete")
@Produces(MediaType.APPLICATION_JSON)
public Response complete(@PathParam("TxId") String txId) throws NotFoundException {
    Activity activity = activityService.getActivity(txId);
    activity.status = CompensatorStatus.Completed;
    activity.statusUrl = String.format("%s/%s/activity/completed", context.getBaseUri(), txId);
    return Response.ok(activity.statusUrl).build();
}
Also used : Activity(io.narayana.lra.participant.model.Activity) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Aggregations

Activity (io.narayana.lra.participant.model.Activity)11 Path (javax.ws.rs.Path)10 PUT (javax.ws.rs.PUT)7 Produces (javax.ws.rs.Produces)7 LRA (io.narayana.lra.annotation.LRA)4 NestedLRA (io.narayana.lra.annotation.NestedLRA)4 GET (javax.ws.rs.GET)2 Compensate (io.narayana.lra.annotation.Compensate)1 CompensatorStatus (io.narayana.lra.annotation.CompensatorStatus)1 Complete (io.narayana.lra.annotation.Complete)1 Forget (io.narayana.lra.annotation.Forget)1 Status (io.narayana.lra.annotation.Status)1 TimeLimit (io.narayana.lra.annotation.TimeLimit)1 IllegalLRAStateException (io.narayana.lra.client.IllegalLRAStateException)1 DELETE (javax.ws.rs.DELETE)1 NotFoundException (javax.ws.rs.NotFoundException)1