You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/11/30 16:53:57 UTC

(camel) branch main updated (8721f2ccccc -> 822c041a65d)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from 8721f2ccccc CAMEL-21474: camel-smb - Add disconnect option
     new 03f88a5a402 CAMEL-21494: camel-file/camel-ftp - Producer should be AsyncProducer based
     new 822c041a65d CAMEL-21400: Add doc about split & aggregate combo using completionSize(1) issue

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/component/file/GenericFileProducer.java   | 21 ++++++++++++++++++---
 .../component/file/remote/RemoteFileProducer.java   |  2 +-
 .../file/remote/integration/FtpLoginIT.java         |  4 ++++
 .../file/remote/integration/FtpLoginNoRetryIT.java  |  4 ++++
 .../FtpThrowExceptionOnConnectionFailedIT.java      |  4 ++++
 .../main/docs/modules/eips/pages/aggregate-eip.adoc | 11 +++++++++++
 6 files changed, 42 insertions(+), 4 deletions(-)


(camel) 02/02: CAMEL-21400: Add doc about split & aggregate combo using completionSize(1) issue

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 822c041a65dc78f4f934df754dd8ff772eccd02f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Nov 30 17:37:53 2024 +0100

    CAMEL-21400: Add doc about split & aggregate combo using completionSize(1) issue
---
 .../src/main/docs/modules/eips/pages/aggregate-eip.adoc       | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/aggregate-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/aggregate-eip.adoc
index 1dcff1dfcec..548f0b7ca57 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/aggregate-eip.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/aggregate-eip.adoc
@@ -694,3 +694,14 @@ public final class MyUserAppender {
 
 Notice that the return type is a `List` which we want to contain the name of the users.
 The first parameter is the `List` of names, and the second parameter is the incoming `com.foo.User` type.
+
+=== Aggregating after large split
+
+If you use the xref:split-eip.adoc[Split] EIP before this aggregator then beware that if you
+use a completion condition, such as `completionSize(1)` then this can lead to the current thread
+being over utilized and its thread-stack becomes very large, and the JVM can throw `StackOverflowException`.
+
+The reason is that same thread is both doing the large split, the aggregation, and also the completion
+of the aggregator all in the same thread. This can lead to deep thread-stacks. To avoid this,
+you can ensure the aggregator uses a different thread to process the completion routing, by enabling `parallelProcessing(true)`.
+


(camel) 01/02: CAMEL-21494: camel-file/camel-ftp - Producer should be AsyncProducer based

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 03f88a5a402313280b3852399633114041cc1a21
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Nov 30 10:42:45 2024 +0100

    CAMEL-21494: camel-file/camel-ftp - Producer should be AsyncProducer based
---
 .../camel/component/file/GenericFileProducer.java   | 21 ++++++++++++++++++---
 .../component/file/remote/RemoteFileProducer.java   |  2 +-
 .../file/remote/integration/FtpLoginIT.java         |  4 ++++
 .../file/remote/integration/FtpLoginNoRetryIT.java  |  4 ++++
 .../FtpThrowExceptionOnConnectionFailedIT.java      |  4 ++++
 5 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
index 2f5031cb70f..22f3eff0c42 100644
--- a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
+++ b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
@@ -22,10 +22,11 @@ import java.util.Map;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
+import org.apache.camel.AsyncCallback;
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
+import org.apache.camel.support.DefaultAsyncProducer;
 import org.apache.camel.support.DefaultExchange;
-import org.apache.camel.support.DefaultProducer;
 import org.apache.camel.support.LRUCacheFactory;
 import org.apache.camel.support.MessageHelper;
 import org.apache.camel.support.service.ServiceHelper;
@@ -39,7 +40,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Generic file producer
  */
-public class GenericFileProducer<T> extends DefaultProducer {
+public class GenericFileProducer<T> extends DefaultAsyncProducer {
     private static final Logger LOG = LoggerFactory.getLogger(GenericFileProducer.class);
 
     protected final GenericFileEndpoint<T> endpoint;
@@ -63,7 +64,18 @@ public class GenericFileProducer<T> extends DefaultProducer {
     }
 
     @Override
-    public void process(Exchange exchange) throws Exception {
+    public boolean process(Exchange exchange, AsyncCallback callback) {
+        try {
+            doProcess(exchange);
+        } catch (Exception e) {
+            exchange.setException(e);
+        } finally {
+            callback.done(true);
+        }
+        return true;
+    }
+
+    protected void doProcess(Exchange exchange) throws Exception {
         // store any existing file header which we want to keep and propagate
         final String existing = exchange.getIn().getHeader(FileConstants.FILE_NAME, String.class);
 
@@ -78,6 +90,8 @@ public class GenericFileProducer<T> extends DefaultProducer {
         lock.lock();
         try {
             processExchange(exchange, target);
+        } catch (Exception e) {
+            exchange.setException(e);
         } finally {
             // do not remove as the locks cache has an upper bound
             // this ensure the locks is appropriate reused
@@ -512,4 +526,5 @@ public class GenericFileProducer<T> extends DefaultProducer {
         super.doStop();
         ServiceHelper.stopService(locks);
     }
+
 }
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
index 29c6269ee50..16e20a05957 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
@@ -50,7 +50,7 @@ public class RemoteFileProducer<T> extends GenericFileProducer<T> {
     }
 
     @Override
-    public void process(Exchange exchange) throws Exception {
+    protected void doProcess(Exchange exchange) throws Exception {
         // store any existing file header which we want to keep and propagate
         final String existing = exchange.getIn().getHeader(FtpConstants.FILE_NAME, String.class);
 
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpLoginIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpLoginIT.java
index cc97c89ec6b..87aca863193 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpLoginIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpLoginIT.java
@@ -69,5 +69,9 @@ public class FtpLoginIT extends FtpServerTestSupport {
         producer.start();
         producer.process(exchange);
         producer.stop();
+
+        if (exchange.isFailed()) {
+            throw exchange.getException();
+        }
     }
 }
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpLoginNoRetryIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpLoginNoRetryIT.java
index 909c9761a5d..d967405e12d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpLoginNoRetryIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpLoginNoRetryIT.java
@@ -60,5 +60,9 @@ public class FtpLoginNoRetryIT extends FtpServerTestSupport {
         producer.start();
         producer.process(exchange);
         producer.stop();
+
+        if (exchange.isFailed()) {
+            throw exchange.getException();
+        }
     }
 }
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpThrowExceptionOnConnectionFailedIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpThrowExceptionOnConnectionFailedIT.java
index 68eeebff422..fcf9f1f8470 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpThrowExceptionOnConnectionFailedIT.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpThrowExceptionOnConnectionFailedIT.java
@@ -60,6 +60,10 @@ public class FtpThrowExceptionOnConnectionFailedIT extends FtpServerTestSupport
         producer.start();
         producer.process(exchange);
         producer.stop();
+
+        if (exchange.isFailed()) {
+            throw exchange.getException();
+        }
     }
 
 }