You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've followed the github step to generate the examples for shardingsphere
and in this example, it runs the named run method to implement xa transaction, while I don't find any annotation on this method, this method only create table, insert records and then drop tables, so I doubt if it can show the function of xa transaction, I've tested in my way:
first, add the transaction type in config file as the sample do:
and then add the bean class as the sample do:
and then import it as the sample do:
and at last, I write a simple method to test it:
@Operation(summary = "测试XA事务")
@PostMapping("/saveContractForXA")
public ResponseResult<Void> saveContractForXA() {
for (int i = 0; i < 10; i++) {
if (i == 6) {
int j = 8 / 0;
}
ContractEntity contract = new ContractEntity();
contract.setContractName(RandomUtil.randomString(8));
contractMapper.insert(contract);
}
return ResponseResult.success();
}
in this method, I throw an exception when I've inserted 6 records, if the xa transaction works, it will rollback when the exception appears, while actually, 6 records are inserted into the table, so what have I omitted for xa transaction?
btw: in old version of shardingsphere like 4.X, I should add annotation like @ShardingTransactionType(value = TransactionType.XA), while in the 5.X version, I don't find this annotation, and in the sample generated above, I don't find any annotation on the method
The text was updated successfully, but these errors were encountered:
version: 5.4.1
I've followed the github step to generate the examples for shardingsphere
and in this example, it runs the named run method to implement xa transaction, while I don't find any annotation on this method, this method only create table, insert records and then drop tables, so I doubt if it can show the function of xa transaction, I've tested in my way:
first, add the transaction type in config file as the sample do:
and then add the bean class as the sample do:
and then import it as the sample do:
and at last, I write a simple method to test it:
in this method, I throw an exception when I've inserted 6 records, if the xa transaction works, it will rollback when the exception appears, while actually, 6 records are inserted into the table, so what have I omitted for xa transaction?
btw: in old version of shardingsphere like 4.X, I should add annotation like @ShardingTransactionType(value = TransactionType.XA), while in the 5.X version, I don't find this annotation, and in the sample generated above, I don't find any annotation on the method
The text was updated successfully, but these errors were encountered: