It looks good to me.

Willem Jiang

Twitter: willemjiang
Weibo: 姜宁willem

On Mon, Nov 25, 2019 at 9:35 PM Zhang Lei <coolbee...@gmail.com> wrote:
>
> Hi,
>
> Yes, they are  class exception, Maybe the following name will be better
>
> class BusinessCompensationFailureException
> class OmegaConnectedException
>
> My idea is to catch an exception and send a compensation result in the
> compensation method[1] on the Omega side. You can see it in the following
> TODO position
>
> public void apply(String globalTxId, String localTxId, String
> callbackMethod, Object... payloads) {
>   CallbackContextInternal contextInternal = contexts.get(callbackMethod);
>   String oldGlobalTxId = omegaContext.globalTxId();
>   String oldLocalTxId = omegaContext.localTxId();
>   try {
>     omegaContext.setGlobalTxId(globalTxId);
>     omegaContext.setLocalTxId(localTxId);
>     contextInternal.callbackMethod.invoke(contextInternal.target, payloads);
>     LOG.info("Callback transaction with global tx id [{}], local tx id
> [{}]", globalTxId, localTxId);
>
>     // TODO send TxCompensateSucceedAckEvent to Alpha
>
>   } catch (IllegalAccessException | InvocationTargetException e) {
>     LOG.error(
>         "Pre-checking for callback method " +
> contextInternal.callbackMethod.toString()
>             + " was somehow skipped, did you forget to configure callback
> method checking on service startup?",
>         e);
>
>     // TODO send TxCompensateFailedAckEvent to Alpha
>
>   } finally {
>     omegaContext.setGlobalTxId(oldGlobalTxId);
>     omegaContext.setLocalTxId(oldLocalTxId);
>   }
> }
>
>
> Alpha waits for compensation result and catching exception after calling
> compensation method
>
> 1. Received TxCompensateSucceedAckEvent: transaction completed
> 2. Received TxCompensateFailedAckEvent: throw
> BusinessCompensationFailureException
> 3. catch other exception throw OmegaConnectedException
>
>
> [1]
> https://github.com/apache/servicecomb-pack/blob/a89c7cd8b416c9b281fdbe28644cb6b7e2e78f91/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/CallbackContext.java#L43
>
> [2]
> https://github.com/apache/servicecomb-pack/blob/694b8d701097226d898e7a342c902ff711caa3cf/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/fsm/GrpcOmegaCallback.java#L35
>
>
> Best regards,
> Lei Zhang
>
> On November 25, 2019 at 7:49:47 PM, Zheng Feng (zh.f...@gmail.com) wrote:
>
> Hi,
>
> I wonder how we can diff the "Omega compensation failure" from the
> "Business compensation failure" ? the different exception classes ?
>
> Zhang Lei <coolbee...@gmail.com> 于2019年11月25日周一 下午5:32写道:
>
> > Hi, Pack Team
> >
> > Currently, Alpha compensation mechanism has some defects [1], I plan to
> > solve this problem step by step [2]
> >
> > Step1: Modify the OnConnected method to bidirectional streaming RPC
> >
> > This will be needed for the Step2
> >
> > Step2: Custom compensation exception rules to distinguish between
> business
> > compensation exceptions and framework compensation exceptions for FSM.
> >
> > After calling the compensation method, Alpha needs to wait for
> > Omega to send a compensation result message. The message type is as
> > follows:
> >
> > Successful compensation:
> > Business compensation failure:business code throws an exception,
> > Do not switch Omega instance and retry(Retry rule is implemented in the
> > Step3)
> > Omega compensation failure: omega code throws an exception,
> > switch other Omega instance and retry(Retry rule is implemented in the
> > Step3)
> >
> >
> > Step3. Added retry and timeout rule to compensate for failures
> >
> > Exceeded the number of retries or timeout will change state to
> > suspended
> >
> > Any Suggestion?
> >
> > [1] https://github.com/apache/servicecomb-pack/issues/590
> > [2] https://github.com/apache/servicecomb-pack/pull/607
> >
> > Best regards,
> > Lei Zhang
> >
> >
> > Best regards,
> > Lei Zhang
> >

Reply via email to