STM in Quarkus
epbernard Oct 15, 2019 2:57 AMHi there,
Here are some quick comments based on my reading of https://quarkus.io/guides/stm-guide
It's a bit unfortunate that the STM engine uses @Transactional (org.jboss.stm.annotations.Transactional) for tx object marking.
In an IDE, it conflicts with Java's @Transactional (javax.transaction.Transactional).
Since Quarkus is doing work at build time, we could reuse the Hibernate with Panache approach for STM and avoid the cumbersome passage to Interface and container for object creation. This needs to be fleshed out but it would be much clearer to get something like this
FlightService fs = FlightService.stmInstance();
//maybe also adding
FlightService fs = new FlightService();
...
fs.enableStm();
//unless a new should always create a container.
Note that this no longer has to be a an interface
Then we could hide AtomicAction demarcation and reuse @Transactional (javax.transaction.Transactional) for user code demarcation.
@Transactional
public String processOrders() {
Order order = Order.stmInstance();
order.validate();
order.process();
}
Would be equivalent to the current
AtomicAction aa = new AtomicAction();
Container<Order> container = new Container<>();
OrderImpl instance = new OrderImpl();
Order order = container.create(instance);
aa.begin();
{
try {
order.validate();
order.process();
aa.commit();
} catch (Exception e) {
aa.abort();
}
}
Note that it's confusing to me whether STM applies to services or actual state object like beans? The doc mentions a FlightService but the Narayana doc seems to mention rather an Bean like object. I think we miss more real case usages or something that looks like a real case usage. Maybe you could write a Todo list managment example using STM.
There is a lot we can do to make this much more user friendly.