for option 2, the two events must be the same thread, and can set and clear
safely

Willem Jiang <willem.ji...@gmail.com> 于2019年1月22日周二 上午9:12写道:

> Hi jimin,
>
> Thanks for the suggestion.
> I think the hardest part of this work is handling thread switching
> work,  event we could clean up the OmegaContext when the
> InvocationBusinessMethodFinishEvent happened, we still need to find
> the right moment to setup the OmegaContext.  So I think the option 1
> is the best way to go.
>
> Willem Jiang
>
> Twitter: willemjiang
> Weibo: 姜宁willem
>
> On Mon, Jan 21, 2019 at 10:51 PM wjm wjm <zzz...@gmail.com> wrote:
> >
> > 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