zhfeng commented on issue #346: compensation method invoke before compensable 
method
URL: 
https://github.com/apache/servicecomb-pack/issues/346#issuecomment-447706649
 
 
   @stashslash I agree with you that the Omega reports the COMPENSATING STATUS 
during the compensate method invoked. So if we only have the 
bookings.get(id).cancel() in the compensate method, let's see what could happen
   
   1) everything goes smooth and the booking record has been inserted, and this 
is a good situation that the cancel() can returns OK. The Omega will report 
COMPENSATE_OK.
   
   2) the same as above but the cancel() returns FAIL or throws the exception 
to indicate this status. The Omega will report COMPENSATE_FAIL.
   
   3) The booking record has not been inserted, and the 
bookings.get(id).cancel() will throw the NPE exception I assume. The Omega will 
catch this exception and report COMPENSATING STATUS as we expect the alpha will 
re-invoke this method later. And the booking record will be inserted at last, 
and the cancel() will return OK or FAIL finally. The Omega will report 
COMPENSATE_OK or FAIL.
   
   4) The booking record inserts failed due to the database errors and the 
Omega will catch this exception and mark this saga transaction is FAIL.
   
   So the Omega will be able to know the return values or the exception from 
the cancel() method when reporting the status. It does make sense if we can 
well define these contracts between the framework and the applications.

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