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 2021/02/16 12:47:32 UTC

[camel] branch master updated (3530e69 -> 5c4e533)

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

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


    from 3530e69  Regen
     new 0b2ebae  camel-core - Fluent template to have withHeaders
     new 5c4e533  camel-http - Little optimize and load tests to reuse template to avoid creating garbage objects.

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:
 .../apache/camel/component/http/HttpProducer.java  |  4 +-
 .../camel/component/http/HttpProducerLoadTest.java | 55 +++++-----------------
 .../org/apache/camel/FluentProducerTemplate.java   |  8 ++++
 .../impl/engine/DefaultFluentProducerTemplate.java | 13 +++++
 4 files changed, 37 insertions(+), 43 deletions(-)


[camel] 02/02: camel-http - Little optimize and load tests to reuse template to avoid creating garbage objects.

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

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

commit 5c4e533cf740469fa6b6fd464308dba33ff86a64
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Feb 16 13:46:58 2021 +0100

    camel-http - Little optimize and load tests to reuse template to avoid creating garbage objects.
---
 .../apache/camel/component/http/HttpProducer.java  |  4 +-
 .../camel/component/http/HttpProducerLoadTest.java | 55 +++++-----------------
 2 files changed, 16 insertions(+), 43 deletions(-)

diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
index 4b1dbaf..4278b87 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
@@ -247,7 +247,9 @@ public class HttpProducer extends DefaultProducer {
             }
             httpResponse = executeMethod(httpRequest);
             int responseCode = httpResponse.getStatusLine().getStatusCode();
-            LOG.debug("Http responseCode: {}", responseCode);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Http responseCode: {}", responseCode);
+            }
 
             if (!throwException) {
                 // if we do not use failed exception then populate response for all response codes
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerLoadTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerLoadTest.java
index cd25a64..57ddd62 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerLoadTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerLoadTest.java
@@ -16,6 +16,10 @@
  */
 package org.apache.camel.component.http;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
 import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.handler.DrinkValidationHandler;
@@ -74,51 +78,18 @@ public class HttpProducerLoadTest extends BaseHttpTest {
 
     @Test
     public void testProducerLoad() throws Exception {
+        Map<String, Object> map = new HashMap<>();
+        for (int i = 0; i < 40; i++) {
+            map.put("mykey" + i, "myvalue" + i);
+        }
+
         StopWatch watch = new StopWatch();
+
+        Endpoint to = getMandatoryEndpoint("direct:echo");
         for (int i = 0; i < 10000000; i++) {
-            fluentTemplate.to("direct:echo")
-                    .withHeader("a", "aaa")
-                    .withHeader("b", "bbb")
-                    .withHeader("c", "ccc")
-                    .withHeader("d", "ddd")
-                    .withHeader("e", "eee")
-                    .withHeader("f", "fff")
-                    .withHeader("g", "ggg")
-                    .withHeader("h", "hhh")
-                    .withHeader("i", "iii")
-                    .withHeader("j", "jjj")
-                    .withHeader("a2", "aaa")
-                    .withHeader("b2", "bbb")
-                    .withHeader("c2", "ccc")
-                    .withHeader("d2", "ddd")
-                    .withHeader("e2", "eee")
-                    .withHeader("f2", "fff")
-                    .withHeader("g2", "ggg")
-                    .withHeader("h2", "hhh")
-                    .withHeader("i2", "iii")
-                    .withHeader("j2", "jjj")
-                    .withHeader("a3", "aaa")
-                    .withHeader("b3", "bbb")
-                    .withHeader("c3", "ccc")
-                    .withHeader("d3", "ddd")
-                    .withHeader("e3", "eee")
-                    .withHeader("f3", "fff")
-                    .withHeader("g3", "ggg")
-                    .withHeader("h3", "hhh")
-                    .withHeader("i3", "iii")
-                    .withHeader("j3", "jjj")
-                    .withHeader("a4", "aaa")
-                    .withHeader("b4", "bbb")
-                    .withHeader("c4", "ccc")
-                    .withHeader("d4", "ddd")
-                    .withHeader("e4", "eee")
-                    .withHeader("f4", "fff")
-                    .withHeader("g4", "ggg")
-                    .withHeader("h4", "hhh")
-                    .withHeader("i4", "iii")
-                    .withHeader("j4", "jjj")
-                    .withHeader("myHeader", "msg" + i).send();
+            template.sendBodyAndHeaders(to, "Message " + i, map);
         }
+
         LOG.info("Took {} ms", watch.taken());
     }
 


[camel] 01/02: camel-core - Fluent template to have withHeaders

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

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

commit 0b2ebaed63a900fb239e892d0d355983ac8e9909
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Feb 16 13:37:43 2021 +0100

    camel-core - Fluent template to have withHeaders
---
 .../main/java/org/apache/camel/FluentProducerTemplate.java  |  8 ++++++++
 .../camel/impl/engine/DefaultFluentProducerTemplate.java    | 13 +++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/core/camel-api/src/main/java/org/apache/camel/FluentProducerTemplate.java b/core/camel-api/src/main/java/org/apache/camel/FluentProducerTemplate.java
index 243dd2f..068573b 100644
--- a/core/camel-api/src/main/java/org/apache/camel/FluentProducerTemplate.java
+++ b/core/camel-api/src/main/java/org/apache/camel/FluentProducerTemplate.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel;
 
+import java.util.Map;
 import java.util.concurrent.Future;
 import java.util.function.Supplier;
 
@@ -146,6 +147,13 @@ public interface FluentProducerTemplate extends Service {
     FluentProducerTemplate clearAll();
 
     /**
+     * Set the headers
+     *
+     * @param headers the headers
+     */
+    FluentProducerTemplate withHeaders(Map<String, Object> headers);
+
+    /**
      * Set the header
      *
      * @param key   the key of the header
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultFluentProducerTemplate.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultFluentProducerTemplate.java
index 68aa64d..7d47e78 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultFluentProducerTemplate.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultFluentProducerTemplate.java
@@ -174,6 +174,19 @@ public class DefaultFluentProducerTemplate extends ServiceSupport implements Flu
     }
 
     @Override
+    public FluentProducerTemplate withHeaders(Map<String, Object> headers) {
+        DefaultFluentProducerTemplate clone = checkCloned();
+
+        Map<String, Object> map = clone.headers;
+        if (map == null) {
+            map = new LinkedHashMap<>();
+            clone.headers = map;
+        }
+        map.putAll(headers);
+        return clone;
+    }
+
+    @Override
     public FluentProducerTemplate withHeader(String key, Object value) {
         DefaultFluentProducerTemplate clone = checkCloned();