in saga/saga-app/src/main/java/org/apache/camel/example/saga/SagaRoute.java [25:49]
public void configure() throws Exception {
rest().post("/saga")
.param().type(RestParamType.query).name("id").dataType("int").required(true).endParam()
.to("direct:saga");
from("direct:saga")
.saga()
.compensation("direct:cancelOrder")
.log("Executing saga #${header.id} with LRA ${header.Long-Running-Action}")
.setHeader("payFor", constant("train"))
.to("jms:queue:{{example.services.train}}?exchangePattern=InOut" +
"&replyTo={{example.services.train}}.reply")
.log("train seat reserved for saga #${header.id} with payment transaction: ${body}")
.setHeader("payFor", constant("flight"))
.to("jms:queue:{{example.services.flight}}?exchangePattern=InOut" +
"&replyTo={{example.services.flight}}.reply")
.log("flight booked for saga #${header.id} with payment transaction: ${body}")
.setBody(header("Long-Running-Action"))
.end();
from("direct:cancelOrder")
.log("Transaction ${header.Long-Running-Action} has been cancelled due to flight or train failure");
}