Updated Branches:
  refs/heads/camel-2.12.x f4e8d9aa0 -> a256e411f

Polished.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a256e411
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a256e411
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a256e411

Branch: refs/heads/camel-2.12.x
Commit: a256e411f9008a705d0f2371324d0491c28c11ef
Parents: f4e8d9a
Author: Babak Vahdat <bvah...@apache.org>
Authored: Thu Nov 14 21:58:49 2013 +0100
Committer: Babak Vahdat <bvah...@apache.org>
Committed: Thu Nov 14 22:00:36 2013 +0100

----------------------------------------------------------------------
 .../apache/camel/component/cxf/CxfEndpoint.java    |  4 +---
 .../apache/camel/component/mina/MinaHelper.java    | 10 +++++-----
 .../apache/camel/component/mina2/Mina2Helper.java  | 17 ++++++++++++-----
 3 files changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a256e411/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
index 5e7e941..c63c1a2 100644
--- 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
+++ 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
@@ -951,9 +951,7 @@ public class CxfEndpoint extends DefaultEndpoint implements 
HeaderFilterStrategy
                 }
 
                 if (elements != null && content.size() < elements.size()) {
-                    LOG.warn("Cannot set right payload parameters. Please 
check the BindingOperation and PayLoadMessage.");
-                    throw new IllegalArgumentException(
-                        "The PayLoad elements cannot fit with the message 
parts of the BindingOperation. Please check the BindingOperation and 
PayLoadMessage.");
+                    throw new IllegalArgumentException("The PayLoad elements 
cannot fit with the message parts of the BindingOperation. Please check the 
BindingOperation and PayLoadMessage.");
                 }
 
                 message.setContent(List.class, content);

http://git-wip-us.apache.org/repos/asf/camel/blob/a256e411/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaHelper.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaHelper.java
 
b/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaHelper.java
index 7772759..f814995 100644
--- 
a/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaHelper.java
+++ 
b/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaHelper.java
@@ -35,7 +35,8 @@ public final class MinaHelper {
     }
 
     /**
-     * Writes the given body to MINA session. Will wait until the body has 
been written.
+     * Asynchronous writes the given body to MINA session. Will wait at most 
for
+     * 10 seconds until the body has been written.
      *
      * @param session  the MINA session
      * @param body     the body to write (send)
@@ -48,11 +49,10 @@ public final class MinaHelper {
         WriteFuture future = session.write(body);
         // must use a timeout (we use 10s) as in some very high performance 
scenarios a write can cause 
         // thread hanging forever
-        LOG.trace("Waiting for write to complete");
-        future.join(10 * 1000L);
+        LOG.trace("Waiting for write to complete for body: {} using session: 
{}", body, session);
+        future.join(10000L);
         if (!future.isWritten()) {
-            LOG.warn("Cannot write body: " + body + " using session: " + 
session);
-            throw new CamelExchangeException("Cannot write body", exchange);
+            throw new CamelExchangeException("Cannot write body: " + body + " 
using session: " + session, exchange);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/a256e411/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Helper.java
----------------------------------------------------------------------
diff --git 
a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Helper.java
 
b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Helper.java
index b25eab1..56ca48f 100644
--- 
a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Helper.java
+++ 
b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Helper.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.mina2;
 
 import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
+import org.apache.mina.core.future.WriteFuture;
 import org.apache.mina.core.session.IoSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -34,7 +35,8 @@ public final class Mina2Helper {
     }
 
     /**
-     * Writes the given body to MINA session. Will wait until the body has 
been written.
+     * Asynchronous writes the given body to MINA session. Will wait at most 
for
+     * 10 seconds until the body has been written.
      *
      * @param session  the MINA session
      * @param body     the body to write (send)
@@ -42,9 +44,14 @@ public final class Mina2Helper {
      * @throws CamelExchangeException is thrown if the body could not be 
written for some reasons
      *                                (eg remote connection is closed etc.)
      */
-    public static void writeBody(IoSession session, Object body, Exchange 
exchange) throws CamelExchangeException {
-        LOG.trace("write exchange [{}] with body [{}]", exchange, body);
-        // the write operation is asynchronous
-        session.write(body);
+    public static void writeBody(IoSession session, Object body, Exchange 
exchange) throws CamelExchangeException, InterruptedException {
+        // the write operation is asynchronous. Use WriteFuture to wait until 
the session has been written
+        WriteFuture future = session.write(body);
+        // must use a timeout (we use 10s) as in some very high performance 
scenarios a write can cause 
+        // thread hanging forever
+        LOG.trace("Waiting for write to complete for body: {} using session: 
{}", body, session);
+        if (!future.awaitUninterruptibly(10000L)) {
+            throw new CamelExchangeException("Cannot write body: " + body + " 
using session: " + session, exchange);
+        }
     }
 }

Reply via email to