cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: SuspendedInvocationException is lost during continuation.suspend()
Date Tue, 23 Nov 2010 12:04:10 GMT
Hi Willem

thanks for the explanation. It makes sense.

However, when a user calls, for ex,

continuation.suspend(60)

there is no need to register a handler. This is a different kind of flow
where a handler is registered and then that handler calls
continuation.resume(). When we do

continuation.suspend(60)

we actually expect an invocation come back to us in the resumed state with
the runtime itself initiating a resume event. I do not need to add a
handler. I can check if some condition has been met when the invocation
comes back.

It is unfortunate Continuation is the interface otherwise we could add a
method like suspendImmediately() may be.

The Jetty wiki is showing

continuation.suspend()

which is the indefinite suspend thus there's a need there to wake up the
pending thread from the application code.

That said, having both timed suspends and async resumes at the same time
makes sense too.

Basically, having an explicit return is not a big issue, but it can make the
user code a bit more involved.

cheers, Sergey

On Tue, Nov 23, 2010 at 4:52 AM, Willem Jiang <willem.jiang@gmail.com>wrote:

> On 11/23/10 1:56 AM, Sergey Beryozkin wrote:
>
>> Hi
>>
>> I've found out, while working with CXF Continuations API recently is that
>>
>> continuation.suspend()
>>
>> is returning normally and no SuspendedInvocationException is thrown.
>>
>> This is unexpected in that now, when continuation.suspend() is used
>> directly
>> in the application code, the explicit 'return' has to be added.
>> This is not too bad when it is done immediately in the top-level service
>> object but if it happens in one of the sub-routines we are effectively
>> have
>> no way of
>> knowing at the start of the call if it was suspended or not, unless we use
>> check the status explicitly :
>>
>> Ex :
>>
>> public void soapMethod() {
>>    doIt();
>>
>>    if (!continuation.isPending()) {
>>        dontDoItIfSuspended();
>>    }
>> }
>>
>> private void doIt() {
>>     continuation.suspend();
>> }
>>
>> Willem - is it how the explicit continuations code has to be written now ?
>>
>>  Yes, that is what I want to do in CXF 2.3.0.
> In this way we can implement suspend resume pattern[1] easily as Jetty 7
> does.
>
> The main reason that continuation.suspend() does not return immediately is
> letting the user have chance to setup the callback method for contination
> resuming. In this way we can make sure the continuation.resume() will never
> be called before the continuation.suspend.
>
>  thanks, Sergey
>>
>>  [1]
> http://wiki.eclipse.org/Jetty/Feature/Continuations#Suspend_Resume_Pattern
>
> --
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>         http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message