Currently learning mutiny and transactions with hibernate-reactive. I need to save Mess Object in database and if there is a specific condition I want to roll back the transaction sending some kind of failure message as return parameter of the save method.
How could I produce Failure or Exception. What would be the best practice in such cases.
Could you please show me an example using this code snippet.
public Uni<Mess> save(Mess mess) {
return Panache.withTransaction(() -> {
if(mess.message.equals("Hello World")){
Panache.currentTransaction().invoke(Transaction::markForRollback).subscribe().with(item -> Log.info("Transaction is marked for roll-back"));
}
return persist(mess);
});
}