zhfeng commented on issue #346: compensation method invoke before compensable 
method
URL: 
https://github.com/apache/servicecomb-pack/issues/346#issuecomment-447250526
 
 
   @stashslash I think the compensate still needs to return the result to 
indicate if it has finished the work.
   
   ```
   CompensateStatus cancel(HotelBooking booking) {
       Integer id = booking.getId();
       try {
           if (bookings.containsKey(id)) {
               bookings.get(id).cancel();
               return COMPENSATE_OK;  // we finish the compensate work 
           } else {
               return COMPENSATING; // we can not find the booking record to be 
compensated and it's maybe ongoing, so it needs to be re-invoked later
           }
       } catch (Exception e) {
              return COMPENSATE_FAIL; // sorry, we can not do the compensate 
work because there is something throws the exception
       }
   }
   ```
   The alpha will check the status by asking the Omega to report it 
periodically until the compensate is OK or FAIL. 

----------------------------------------------------------------
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