Author: gnodet
Date: Tue Aug 22 13:31:34 2006
New Revision: 433739

URL: http://svn.apache.org/viewvc?rev=433739&view=rev
Log:
SM-550: The http provider endpoint should use send instead of sendSync

Modified:
    
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java

Modified: 
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java?rev=433739&r1=433738&r2=433739&view=diff
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java
 (original)
+++ 
incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java
 Tue Aug 22 13:31:34 2006
@@ -58,6 +58,8 @@
 import org.apache.servicemix.soap.marshalers.SoapReader;
 import org.apache.servicemix.soap.marshalers.SoapWriter;
 
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+
 /**
  * 
  * @author Guillaume Nodet
@@ -71,6 +73,7 @@
     protected SoapHelper soapHelper;
     protected DeliveryChannel channel;
     private String relUri;
+    private Map methods;
     
     public ProviderProcessor(HttpEndpoint endpoint) {
         this.endpoint = endpoint;
@@ -86,12 +89,16 @@
         if (uri.getFragment() != null) {
             relUri += "#" + uri.getFragment();
         }
+        this.methods = new ConcurrentHashMap();
     }
 
     public void process(MessageExchange exchange) throws Exception {
-        if (exchange.getStatus() == ExchangeStatus.DONE) {
-            return;
-        } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+        if (exchange.getStatus() == ExchangeStatus.DONE || 
+            exchange.getStatus() == ExchangeStatus.ERROR) {
+            PostMethod method = (PostMethod) 
methods.remove(exchange.getExchangeId());
+            if (method != null) {
+                method.releaseConnection();
+            }
             return;
         }
         NormalizedMessage nm = exchange.getMessage("in");
@@ -129,6 +136,7 @@
             }
         }
         method.setRequestEntity(entity);
+        boolean close = true;
         try {
             // Uncomment to avoid the http request being sent several times.
             // Can be useful when debugging
@@ -171,7 +179,9 @@
                 msg.setProperty(JbiConstants.PROTOCOL_HEADERS, 
getHeaders(method));
                 soapHelper.getJBIMarshaler().toNMS(msg, soapMessage);
                 ((InOut) exchange).setOutMessage(msg);
-                channel.sendSync(exchange);
+                methods.put(exchange.getExchangeId(), method);
+                channel.send(exchange);
+                close = false;
             } else if (exchange instanceof InOptionalOut) {
                 if (method.getResponseContentLength() == 0) {
                     exchange.setStatus(ExchangeStatus.DONE);
@@ -186,14 +196,18 @@
                     msg.setProperty(JbiConstants.PROTOCOL_HEADERS, 
getHeaders(method));
                     soapHelper.getJBIMarshaler().toNMS(msg, soapMessage);
                     ((InOptionalOut) exchange).setOutMessage(msg);
-                    channel.sendSync(exchange);
+                    methods.put(exchange.getExchangeId(), method);
+                    channel.send(exchange);
+                    close = false;
                 }
             } else {
                 exchange.setStatus(ExchangeStatus.DONE);
                 channel.send(exchange);
             }
         } finally {
-            method.releaseConnection();
+            if (close) {
+                method.releaseConnection();
+            }
         }
     }
 


Reply via email to