You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by na...@apache.org on 2006/11/29 18:56:03 UTC

svn commit: r480660 - in /webservices/axis2/trunk/java/modules: kernel/src/org/apache/axis2/engine/ kernel/src/org/apache/axis2/transport/ kernel/src/org/apache/axis2/transport/http/ samples/quickstartaxiom/src/samples/quickstart/clients/

Author: nagy
Date: Wed Nov 29 09:56:02 2006
New Revision: 480660

URL: http://svn.apache.org/viewvc?view=rev&rev=480660
Log:
Added a control object/callback to the transport to allow other components to provide processing information to the transport.  The modifications in this patch allow the AxisServlet to be notified when a one-way message has be processed far enough to be ack'd as per the specs.  (A similar change, although warranted, was not made to the SimpleHTTPServer, as the API does not seem to provide a means to return a response without unwinding the call stack.)  The quickstart sample was modified to fix a dependency that it had upon fire-and-forget invocations not returning until the one-way message had been completely processed on the server side (at least in the case of Axis2.)

Added:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java
Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
    webservices/axis2/trunk/java/modules/samples/quickstartaxiom/src/samples/quickstart/clients/AXIOMClient.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java?view=diff&rev=480660&r1=480659&r2=480660
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java Wed Nov 29 09:56:02 2006
@@ -1,10 +1,13 @@
 package org.apache.axis2.engine;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.transport.RequestResponseTransport;
+import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2004Constants;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -65,6 +68,17 @@
         if ((msgContext.getAxisService() == null) && (msgContext.getServiceContext() != null)) {
             msgContext.setAxisService(msgContext.getServiceContext().getAxisService());
         }
+        
+        //TODO: The same thing should probably happen for a IN-OUT if addressing is enabled and the replyTo/faultTo are not anonymous 
+        if (msgContext.getAxisOperation().getMessageExchangePattern().equals(WSDL20_2004Constants.MEP_URI_IN_ONLY))
+        {
+          Object requestResponseTransport = msgContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
+          if (requestResponseTransport != null)
+          {
+            ((RequestResponseTransport)requestResponseTransport).acknowledgeMessage(msgContext);
+          }
+        }
+
         ArrayList operationChain = msgContext.getAxisOperation().getRemainingPhasesInFlow();
         msgContext.setExecutionChain((ArrayList) operationChain.clone());
     }

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java?view=auto&rev=480660
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java Wed Nov 29 09:56:02 2006
@@ -0,0 +1,42 @@
+/*
+* Copyright 2006 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.transport;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+
+/**
+ * This interface represents a control object for a Request/Response transport.
+ * The normal flow of Axis2 is rooted at the transport -- this does not
+ * allow for an acknowledgement to be transmitted before processing has
+ * completed, nor does it allow for processing to be paused and resumed
+ * on a separate thread without having a response be sent back.  This interface
+ * enables both of those scenarios by allowing the transport to expose
+ * controls to the rest of the engine via a callback.     
+ */
+public interface RequestResponseTransport
+{
+  /*This is the name of the property that is to be stored on the
+    MessageContext*/
+  public static final String TRANSPORT_CONTROL
+    = "RequestResponseTransportControl";
+
+  public void acknowledgeMessage(MessageContext msgContext) throws AxisFault;
+  
+  //public void suspendOnReturn(MessageContext msgContext);
+  //public void processResponse(MessageContext msgContext);
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java?view=diff&rev=480660&r1=480659&r2=480660
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java Wed Nov 29 09:56:02 2006
@@ -32,6 +32,7 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.transport.RequestResponseTransport;
 import org.apache.axis2.transport.TransportListener;
 import org.apache.axis2.transport.http.server.HttpUtils;
 import org.apache.axis2.transport.http.util.RESTUtil;
@@ -98,6 +99,8 @@
 
         msgContext.setProperty(Constants.OUT_TRANSPORT_INFO,
                 new ServletBasedOutTransportInfo(resp));
+        msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL,
+                               new ServletRequestResponseTransport(resp));
         msgContext.setProperty(MessageContext.REMOTE_ADDR, req.getRemoteAddr());
         msgContext.setFrom(new EndpointReference(req.getRemoteAddr()));
         msgContext.setProperty(MessageContext.TRANSPORT_HEADERS,
@@ -539,5 +542,31 @@
 
         return ((soapActionHeader == null) ||
                 (contentType != null && contentType.indexOf(HTTPConstants.MEDIA_TYPE_X_WWW_FORM) > -1));
+    }
+    
+    class ServletRequestResponseTransport implements RequestResponseTransport
+    {
+      private HttpServletResponse response;
+      
+      ServletRequestResponseTransport(HttpServletResponse response)
+      {
+        this.response = response;
+      }
+      
+      public void acknowledgeMessage(MessageContext msgContext) throws AxisFault
+      {
+        response.setContentType("text/xml; charset="
+                                + msgContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING));
+        
+        response.setStatus(HttpServletResponse.SC_ACCEPTED);
+        try
+        {
+          response.flushBuffer();
+        }
+        catch (IOException e)
+        {
+          throw new AxisFault("Error sending acknowledgement", e);
+        }
+      }
     }
 }

Modified: webservices/axis2/trunk/java/modules/samples/quickstartaxiom/src/samples/quickstart/clients/AXIOMClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/quickstartaxiom/src/samples/quickstart/clients/AXIOMClient.java?view=diff&rev=480660&r1=480659&r2=480660
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/quickstartaxiom/src/samples/quickstart/clients/AXIOMClient.java (original)
+++ webservices/axis2/trunk/java/modules/samples/quickstartaxiom/src/samples/quickstart/clients/AXIOMClient.java Wed Nov 29 09:56:02 2006
@@ -58,6 +58,7 @@
 
             sender.fireAndForget(updatePayload);
             System.err.println("done");
+            Thread.sleep(3000);
             OMElement result = sender.sendReceive(getPricePayload);
 
             String response = result.getFirstElement().getText();



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Re: svn commit: r480660 - in /webservices/axis2/trunk/java/modules: kernel/src/org/apache/axis2/engine/ kernel/src/org/apache/axis2/transport/ kernel/src/org/apache/axis2/transport/http/ samples/quickstartaxiom/src/samples/quickstart/clients/

Posted by Bill Nagy <na...@watson.ibm.com>.
Hi Sanjiva,

The acknowledgeMessage(...) method relies upon the transport being able
to respond before the initial call into the Axis2 code (e.g. doPost) is
unwound -- this works for the servlet transport as the
ServletResponse.flushBuffer() method commits the response then and
there, but doesn't work for the SimpleHTTPServer as I pointed out,
because the commons API doesn't seem to provide a similar mechanism.
The SimpleHTTPServer's implementation of acknowledgeMessage(...) (and
any others like it), with a little more work, could pause the message
and spawn another thread to continue processing, allowing the original
thread to be unwound and a response to be sent out as you indicated.
This seems rather ugly to me; I think a better solution would be to
convince the commons API folks to add the same functionality as the
Servlet API.

-Bill
  
On Thu, 2006-11-30 at 13:43 +0530, Sanjiva Weerawarana wrote:
> On Wed, 2006-11-29 at 17:56 +0000, nagy@apache.org wrote:
> > Author: nagy
> > Date: Wed Nov 29 09:56:02 2006
> > New Revision: 480660
> > 
> > URL: http://svn.apache.org/viewvc?view=rev&rev=480660 Log: Added a
> >  control object/callback to the transport to allow other components to
> >  provide processing information to the transport.  The modifications in
> >  this patch allow the AxisServlet to be notified when a one-way message
> >  has be processed far enough to be ack'd as per the specs.  (A similar
> >  change, although warranted, was not made to the SimpleHTTPServer, as
> >  the API does not seem to provide a means to return a response without
> >  unwinding the call stack.)  The quickstart sample was modified to fix
> >  a dependency that it had upon fire-and-forget invocations not
> >  returning until the one-way message had been completely processed on
> >  the server side (at least in the case of Axis2.)
> 
> This is very cool. How does the transport actually finish the message
> though? I mean does it use the thread that's calling
> acknowledgeMessage() to do whatever is needed then and there or rely on
> some other thread coming back to let it fall through to the normal close
> stuff?
> 
> Sanjiva.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Re: svn commit: r480660 - in /webservices/axis2/trunk/java/modules: kernel/src/org/apache/axis2/engine/ kernel/src/org/apache/axis2/transport/ kernel/src/org/apache/axis2/transport/http/ samples/quickstartaxiom/src/samples/quickstart/clients/

Posted by Bill Nagy <na...@watson.ibm.com>.
Hi Sanjiva,

The acknowledgeMessage(...) method relies upon the transport being able
to respond before the initial call into the Axis2 code (e.g. doPost) is
unwound -- this works for the servlet transport as the
ServletResponse.flushBuffer() method commits the response then and
there, but doesn't work for the SimpleHTTPServer as I pointed out,
because the commons API doesn't seem to provide a similar mechanism.
The SimpleHTTPServer's implementation of acknowledgeMessage(...) (and
any others like it), with a little more work, could pause the message
and spawn another thread to continue processing, allowing the original
thread to be unwound and a response to be sent out as you indicated.
This seems rather ugly to me; I think a better solution would be to
convince the commons API folks to add the same functionality as the
Servlet API.

-Bill
  
On Thu, 2006-11-30 at 13:43 +0530, Sanjiva Weerawarana wrote:
> On Wed, 2006-11-29 at 17:56 +0000, nagy@apache.org wrote:
> > Author: nagy
> > Date: Wed Nov 29 09:56:02 2006
> > New Revision: 480660
> > 
> > URL: http://svn.apache.org/viewvc?view=rev&rev=480660 Log: Added a
> >  control object/callback to the transport to allow other components to
> >  provide processing information to the transport.  The modifications in
> >  this patch allow the AxisServlet to be notified when a one-way message
> >  has be processed far enough to be ack'd as per the specs.  (A similar
> >  change, although warranted, was not made to the SimpleHTTPServer, as
> >  the API does not seem to provide a means to return a response without
> >  unwinding the call stack.)  The quickstart sample was modified to fix
> >  a dependency that it had upon fire-and-forget invocations not
> >  returning until the one-way message had been completely processed on
> >  the server side (at least in the case of Axis2.)
> 
> This is very cool. How does the transport actually finish the message
> though? I mean does it use the thread that's calling
> acknowledgeMessage() to do whatever is needed then and there or rely on
> some other thread coming back to let it fall through to the normal close
> stuff?
> 
> Sanjiva.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Re: svn commit: r480660 - in /webservices/axis2/trunk/java/modules: kernel/src/org/apache/axis2/engine/ kernel/src/org/apache/axis2/transport/ kernel/src/org/apache/axis2/transport/http/ samples/quickstartaxiom/src/samples/quickstart/clients/

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Wed, 2006-11-29 at 17:56 +0000, nagy@apache.org wrote:
> Author: nagy
> Date: Wed Nov 29 09:56:02 2006
> New Revision: 480660
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=480660 Log: Added a
>  control object/callback to the transport to allow other components to
>  provide processing information to the transport.  The modifications in
>  this patch allow the AxisServlet to be notified when a one-way message
>  has be processed far enough to be ack'd as per the specs.  (A similar
>  change, although warranted, was not made to the SimpleHTTPServer, as
>  the API does not seem to provide a means to return a response without
>  unwinding the call stack.)  The quickstart sample was modified to fix
>  a dependency that it had upon fire-and-forget invocations not
>  returning until the one-way message had been completely processed on
>  the server side (at least in the case of Axis2.)

This is very cool. How does the transport actually finish the message
though? I mean does it use the thread that's calling
acknowledgeMessage() to do whatever is needed then and there or rely on
some other thread coming back to let it fall through to the normal close
stuff?

Sanjiva.
-- 
Sanjiva Weerawarana, Ph.D.
Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
Director; Open Source Initiative; http://www.opensource.org/
Member; Apache Software Foundation; http://www.apache.org/
Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Re: svn commit: r480660 - in /webservices/axis2/trunk/java/modules: kernel/src/org/apache/axis2/engine/ kernel/src/org/apache/axis2/transport/ kernel/src/org/apache/axis2/transport/http/ samples/quickstartaxiom/src/samples/quickstart/clients/

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Wed, 2006-11-29 at 17:56 +0000, nagy@apache.org wrote:
> Author: nagy
> Date: Wed Nov 29 09:56:02 2006
> New Revision: 480660
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=480660 Log: Added a
>  control object/callback to the transport to allow other components to
>  provide processing information to the transport.  The modifications in
>  this patch allow the AxisServlet to be notified when a one-way message
>  has be processed far enough to be ack'd as per the specs.  (A similar
>  change, although warranted, was not made to the SimpleHTTPServer, as
>  the API does not seem to provide a means to return a response without
>  unwinding the call stack.)  The quickstart sample was modified to fix
>  a dependency that it had upon fire-and-forget invocations not
>  returning until the one-way message had been completely processed on
>  the server side (at least in the case of Axis2.)

This is very cool. How does the transport actually finish the message
though? I mean does it use the thread that's calling
acknowledgeMessage() to do whatever is needed then and there or rely on
some other thread coming back to let it fall through to the normal close
stuff?

Sanjiva.
-- 
Sanjiva Weerawarana, Ph.D.
Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
Director; Open Source Initiative; http://www.opensource.org/
Member; Apache Software Foundation; http://www.apache.org/
Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org