WillemJiang commented on a change in pull request #339: SCB-963 Add Test case 
for saga transactional compensation.
URL: https://github.com/apache/servicecomb-saga/pull/339#discussion_r234836400
 
 

 ##########
 File path: 
omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionalUserService.java
 ##########
 @@ -65,4 +65,17 @@ public void delete(User user, int count) {
     resetCount();
     userRepository.delete(user);
   }
+
+  @Compensable(compensationMethod = "deleteTransactional")
+  public User addTransactional(User user) {
+    if (ILLEGAL_USER.equals(user.username())) {
+      throw new IllegalArgumentException("User is illegal");
+    }
+    return userRepository.save(user);
+  }
+
+  public void deleteTransactional(User user) {
+    userRepository.delete(user);
+    throw new RuntimeException("saga compensation rollback test");
 
 Review comment:
   We just let the user know this method is supposed to be failed and the 
repository operation will be rollback.  Don't worry I will submit a quick fix 
for it after merging your PR.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to