You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/04/13 07:49:54 UTC

[GitHub] [servicecomb-pack] twistycs edited a comment on issue #650: globalTxId is null.

twistycs edited a comment on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-612724272
 
 
     This is Service A Call B, C and D:
   ```
       @SagaStart
       @PostMapping("/contract")
       public ResponseEntity<?> serviceA() {
           try {
               CompletableFuture<Response> insertServiceB= serviceB.insertServiceB();
               CompletableFuture<Response> insertServiceC= serviceC.insertServiceC();
               CompletableFuture<Response> insertServiceD= serviceD.insertServiceD();
               CompletableFuture.allOf(insertServiceB,insertServiceC,insertServiceD).join();
              
           } catch (Exception e) {
               e.printStackTrace();
               return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Can not created .");
           }
           return ResponseEntity.status(HttpStatus.CREATED)
       }
   ```
   ============================================================
   Service B :  
   ```
   @PostMapping()
       public ResponseEntity<?> insertServiceB() {
           try {
               response = serviceB.insertServiceB(customer);
           } catch (final Exception e) {
               e.printStackTrace();
               return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Can not insert.");
           }
           return ResponseEntity.status(HttpStatus.CREATED).body(response);
       }
   ```
   Method Service B :  
   ```
   @Compensable(compensationMethod = "cancel")
       public Response insertServiceB(Customer customer) {
           Response resp = new Response();
           try {
                   insertServiceBRepository.save(customer);
           } catch (Exception e) {
               e.printStackTrace();
           }
           return resp;
       }
   
    void cancel(Customer customer){
           System.out.println("CANCEL CUSTOMER !!!!!!!!!!!!!!!!!!!!!");
       }
   ```
   =======================================================
   
   And Stop Service C 

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


With regards,
Apache Git Services