cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Willem Jiang (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CXF-2982) Don't throw the SuspendedInvocationException when call the suspend() method of CXF continuation
Date Wed, 08 Sep 2010 13:50:33 GMT

    [ https://issues.apache.org/jira/browse/CXF-2982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12907215#action_12907215
] 

Willem Jiang commented on CXF-2982:
-----------------------------------

Before apply the patch, my camel-cxf consumer is like this

{code}
          private Object asyncInvoke(Exchange cxfExchange, final Continuation continuation)
{
                if (continuation.isNew()) {
                    final org.apache.camel.Exchange camelExchange = perpareCamelExchange(cxfExchange);

                    // use the asynchronous API to process the exchange
                    boolean sync = getAsyncProcessor().process(camelExchange, new AsyncCallback()
{
                        public void done(boolean doneSync) {
                            if (LOG.isTraceEnabled()) {
                                LOG.trace("Resuming continuation of exchangeId: "
                                          + camelExchange.getExchangeId());
                            }
                            // resume processing after both, sync and async callbacks
                            continuation.setObject(camelExchange);
                            continuation.resume();
                        }
                    });
                    // just need to avoid the continuation.resume is called
                    // before the continuation.suspend is called
                    if (continuation.getObject() != camelExchange && !sync) {
                        // Now we don't set up the timeout value
                        if (LOG.isTraceEnabled()) {
                            LOG.trace("Suspending continuation of exchangeId: "
                                      + camelExchange.getExchangeId());
                        }
                        // The continuation could be called before the suspend
                        // is called
                        continuation.suspend(0);
                    } else {
                        // just set the response back, as the invoking thread is
                        // not changed
                        if (LOG.isTraceEnabled()) {
                            LOG.trace("Processed the Exchange : " + camelExchange.getExchangeId());
                        }
                        setResponseBack(cxfExchange, camelExchange);
                    }

                }
                if (continuation.isResumed()) {
                    org.apache.camel.Exchange camelExchange = (org.apache.camel.Exchange)continuation
                        .getObject();
                    setResponseBack(cxfExchange, camelExchange);

                }
                return null;
            }
{code}

After applying the patch , my camel-cxf consumer code is much clearer
{code}
          private Object asyncInvoke(Exchange cxfExchange, final Continuation continuation)
{
                if (continuation.isNew()) {
                    final org.apache.camel.Exchange camelExchange = perpareCamelExchange(cxfExchange);
                    // Now we don't set up the timeout value
                    if (LOG.isTraceEnabled()) {
                        LOG.trace("Suspending continuation of exchangeId: "
                                  + camelExchange.getExchangeId());
                    }
                    // now we could call the suspend here
                    continuation.suspend(0);
                    
                    // use the asynchronous API to process the exchange
                    getAsyncProcessor().process(camelExchange, new AsyncCallback() {
                        public void done(boolean doneSync) {
                            if (LOG.isTraceEnabled()) {
                                LOG.trace("Resuming continuation of exchangeId: "
                                          + camelExchange.getExchangeId());
                            }
                            // resume processing after both, sync and async callbacks
                            continuation.setObject(camelExchange);
                            continuation.resume();
                        }
                    });

                }
                if (continuation.isResumed()) {
                    org.apache.camel.Exchange camelExchange = (org.apache.camel.Exchange)continuation
                        .getObject();
                    setResponseBack(cxfExchange, camelExchange);

                }
                return null;
            }
{code}

> Don't throw the SuspendedInvocationException when call the suspend() method of CXF continuation
> -----------------------------------------------------------------------------------------------
>
>                 Key: CXF-2982
>                 URL: https://issues.apache.org/jira/browse/CXF-2982
>             Project: CXF
>          Issue Type: Improvement
>            Reporter: Willem Jiang
>            Assignee: Willem Jiang
>             Fix For: 2.3
>
>         Attachments: cxf-2982.patch
>
>
> Current CXF Continuation suspend implementation is based on throw SuspendedInvocationException,
This  implementation has a shortcoming which cannot call the other framework's  async API
after continuation suspend is called as Jetty7 does.
> So I introduce a flag of Message.CONTINUATION_SUSPENDED to break out current interceptor
chain as the SuspendedInvocation does,  but It will make CXF continuation API more easy to
use and it supports the Jetty7 continuation or Servlet3  suspend resume semantics.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message