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

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


The following commit(s) were added to refs/heads/main by this push:
     new f996004cf37f CAMEL-25891: camel-spring-xml - make SEDA consumers poll 
faster in tests created with SpringTestHelper
f996004cf37f is described below

commit f996004cf37fdf47e4bbe2a7c4c2b80c45ef589e
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Mon Nov 9 22:53:57 2026 +0100

    CAMEL-25891: camel-spring-xml - make SEDA consumers poll faster in tests 
created with SpringTestHelper
    
    ContextTestSupport and SpringTestSupport reduce the default poll timeout of
    the seda component to 10 ms ("make SEDA run faster"), but the 356 test 
classes
    that create their CamelContext with 
SpringTestHelper.createSpringCamelContext
    did not, so their seda consumers kept the default of 1000 ms.
    
    A SedaConsumer blocks in queue.poll(pollTimeout), and stopping the context
    waits for its threads to leave that poll. With several seda routes, each 
test
    spent about 3 seconds in the shutdown of its CamelContext, for example
    "shutdown in 2s993ms" for SpringDelayerTest, whose test bodies take about 2
    seconds.
    
    Set the default poll timeout to 10 ms before the context is started, as the
    other test support classes do.
    
    On the module (1186 tests, 4 forks): the number of context shutdowns taking 
1
    second or more goes from 71 (120 s in total) to 35 (50 s), the sum of the
    class times from 435 s to 317 s and the wall time from about 130 s to 105 s.
    SpringDelayerTest goes from 19 s to 3 s.
    
    Co-authored-by: IBM Bob 2.2.1
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 .../test/java/org/apache/camel/spring/processor/SpringTestHelper.java | 4 ++++
 1 file changed, 4 insertions(+)

diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringTestHelper.java
 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringTestHelper.java
index f54817431067..a51d5c6b1988 100644
--- 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringTestHelper.java
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringTestHelper.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Service;
+import org.apache.camel.component.seda.SedaComponent;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.spring.SpringCamelContext;
 import org.springframework.context.support.AbstractXmlApplicationContext;
@@ -72,6 +73,9 @@ public final class SpringTestHelper {
         }
         
context.getCamelContextExtension().getRegistry().bind(PROPERTY_TEST_DIR, 
test.testDirectory());
         context.getPropertiesComponent().addInitialProperty(PROPERTY_TEST_DIR, 
test.testDirectory().toString());
+        // make SEDA run faster: it must be set before the context is started, 
as the consumers use it to poll their queue
+        // and the shutdown has to wait up to this time for them
+        context.getComponent("seda", 
SedaComponent.class).setDefaultPollTimeout(10);
         if (!isNoStart) {
             context.start();
         }

Reply via email to