I'm using TokuMx
in order to organize a transaction. It has specific commands to do so.
I tried to run db.runCommand("beginTransaction")
in Mongo shell
. It worked well.
However, when I did the same thing in Jongo
:
PlayJongo.jongo().runCommand("beginTransaction");
It gave me [error] play - Cannot invoke the action, eventually got an error: java.lang.IllegalArgumentException: Cannot parse query: beginTransaction
What did I do wrong?
EDIT
public static boolean buyProduct(User buyer, User seller, int accountIndex, float productPrice){
boolean isSuccess = false;
PlayJongo.jongo().runCommand("{beginTransaction : 1}");
try{
// Deposit money to seller
seller.getAccounts().get(0).deposit(productPrice);
UserRepository.update(seller);
// Withdraw money from buyer
buyer.getAccounts().get(accountIndex).withdraw(productPrice);
UserRepository.update(buyer);
throw new Exception();
//isSuccess = true;
}
catch (Exception e){
PlayJongo.jongo().runCommand("{rollbackTransaction : 1 }");
isSuccess = false;
}
return isSuccess;
}
I'm not a jongo expert but I do work on tokumx and I just checked the jongo docs. I think you want