You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2007/04/27 02:48:29 UTC

svn commit: r532923 - /incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java

Author: mriou
Date: Thu Apr 26 17:48:28 2007
New Revision: 532923

URL: http://svn.apache.org/viewvc?view=rev&rev=532923
Log:
Invocation must happen in a separate thread in afterCompletion, otherwise it blocks all other operations listed in the afterCompletion as well.

Modified:
    incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java

Modified: incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java?view=diff&rev=532923&r1=532922&r2=532923
==============================================================================
--- incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java (original)
+++ incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java Thu Apr 26 17:48:28 2007
@@ -19,12 +19,6 @@
 
 package org.apache.ode.axis2;
 
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-
-import javax.wsdl.Definition;
-import javax.xml.namespace.QName;
-
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.AxisFault;
@@ -44,14 +38,19 @@
 import org.apache.ode.bpel.epr.WSAEndpoint;
 import org.apache.ode.bpel.iapi.Message;
 import org.apache.ode.bpel.iapi.MessageExchange;
+import org.apache.ode.bpel.iapi.MessageExchange.FailureType;
 import org.apache.ode.bpel.iapi.PartnerRoleChannel;
 import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
 import org.apache.ode.bpel.iapi.Scheduler;
-import org.apache.ode.bpel.iapi.MessageExchange.FailureType;
 import org.apache.ode.utils.DOMUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+
 /**
  * Acts as a service not provided by ODE. Used mainly for invocation as a way to maintain the WSDL decription of used services.
  * 
@@ -132,22 +131,27 @@
                         if (!success)
                             return;
 
-                        try {
-                            operationClient.execute(true);
-                            MessageContext response = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-                            MessageContext flt = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_FAULT_VALUE);
-                            if (flt != null) {
-                                reply(odeMex, flt, true);
-                            } else {
-                                reply(odeMex, response, false);
+                        // The invocation must happen in a separate thread, holding on the afterCompletion
+                        // blocks other operations that could have been listed there as well.
+                        _executorService.submit(new Callable<Object>() {
+                            public Object call() throws Exception {
+                                try {
+                                    operationClient.execute(true);
+                                    MessageContext response = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+                                    MessageContext flt = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_FAULT_VALUE);
+                                    if (flt != null) {
+                                        reply(odeMex, flt, true);
+                                    } else {
+                                        reply(odeMex, response, false);
+                                    }
+                                } catch (Throwable t) {
+                                    String errmsg = "Error sending message to Axis2 for ODE mex " + odeMex;
+                                    __log.error(errmsg, t);
+                                    replyWithFailure(odeMex, MessageExchange.FailureType.COMMUNICATION_ERROR, errmsg, null);
+                                }
+                                return null;
                             }
-                        } catch (Throwable t) {
-                            String errmsg = "Error sending message to Axis2 for ODE mex " + odeMex;
-                            __log.error(errmsg, t);
-                            replyWithFailure(odeMex, MessageExchange.FailureType.COMMUNICATION_ERROR, errmsg, null);
-                            return;
-                        }
-
+                        });
                     }
 
                     public void beforeCompletion() {
@@ -158,7 +162,12 @@
 
             } else /** one-way case * */
             {
-                operationClient.execute(false);
+                _executorService.submit(new Callable<Object>() {
+                    public Object call() throws Exception {
+                        operationClient.execute(false);
+                        return null;
+                    }
+                });
                 odeMex.replyOneWayOk();
             }
         } catch (AxisFault axisFault) {