all the following solutions can support this:
1.implement a handle, and require customers to configure it to be the last
handler

@Override
public void handle(Invocation invocation, AsyncResponse asyncResp)
throws Exception {
  set context

  try {
    invocation.next(asyncResp);
  } finally {
    clear context
  }
}


2.subscribe events:
    org.apache.servicecomb.core.event.InvocationBusinessMethodStartEvent to
set context, this event means business method will be invoked in this thread
    org.apache.servicecomb.core.event.InvocationBusinessMethodFinishEvent to
clear context, this event means business method already returned in this
thread, for async method, this not means response data model is ready.

    we can get EventBus by org.apache.servicecomb.core.SCBEngine#getEventBus

Willem Jiang <willem.ji...@gmail.com> 于2019年1月21日周一 下午5:16写道:

> Hi,
>
> Current we got an issue[1] to clean up the OmegaContext after the
> invocation on the server side to clean up the thread local variable
> which OmegaContext set.
> Now I have a question for the handler of servicecomb java-chassis. How
> can I do the same thing on the java-chassis SagaProviderHandler[2]?
>
> [1]https://github.com/apache/servicecomb-pack/issues/384
> [2]
> https://github.com/apache/servicecomb-pack/blob/master/omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaProviderHandler.java
>
> Willem Jiang
>
> Twitter: willemjiang
> Weibo: 姜宁willem
>

Reply via email to