in generic-examples/saga/Train.java [26:48]
public void configure() throws Exception {
LRASagaService service = new LRASagaService();
service.setCoordinatorUrl("http://lra-coordinator");
service.setLocalParticipantUrl("http://train");
getContext().addService(service);
rest("/api/").post("/train/buy/seat")
.param().type(RestParamType.header).name("id").required(true).endParam()
.to("direct:buySeat");
from("direct:buySeat")
.saga()
.propagation(SagaPropagation.SUPPORTS)
.option("id", header("id"))
.compensation("direct:cancelPurchase")
.log("Buying train seat #${header.id}")
.removeHeaders("CamelHttp.*")
.to("http://payment/api/pay?httpMethod=POST&type=train")
.log("Payment for train #${header.id} done");
from("direct:cancelPurchase")
.log("Train purchase #${header.id} has been cancelled");
}