Skip to content

Instantly share code, notes, and snippets.

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/b69d3535cebd5085aa1bc16e3a560f18 to your computer and use it in GitHub Desktop.
Save paulparkinson/b69d3535cebd5085aa1bc16e3a560f18 to your computer and use it in GitHub Desktop.
Airline implementation of Oracle Database SagaParticipant
@Participant(name = "Airline")
/* @Participant declares the participant’s name to the saga framework */
public class Airline extends SagaParticipant {
/* Airline extends the SagaParticipant class */
@Request(sender = "TravelAgency")
/* The @Request annotates the method that handles incoming request from a given
sender, in this example the TravelAgency */
public String handleTravelAgencyRequest(SagaMessageContext
info) {
/* Perform all DML with this connection to ensure
everything is in a single transaction */
FlightService fs = new
FlightService(info.getConnection());
fs.bookFlight(info.getPayload(), info.getSagaId());
return response;
/* Local commit is automatically performed by the saga framework.
The response is returned to the initiator */
}
@Compensate
/* @Compensate annotates the method automatically called to roll back a saga */
public void compensate(SagaMessageContext info) {
fs.deleteBooking(info.getPayload(),
info.getSagaId());
}
@Complete
/* @Complete annotates the method automatically called to commit a saga */
public void complete(SagaMessageContext info) {
fs.sendConfirmation(info.getSagaId());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment