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/03/13 14:18:43 UTC

[camel] branch master updated: camel-core - Warump pooled exchange factory on doBuild so the class is loaded eager by the JVM instead of on first exchange use.

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


The following commit(s) were added to refs/heads/master by this push:
     new ed25d5f  camel-core - Warump pooled exchange factory on doBuild so the class is loaded eager by the JVM instead of on first exchange use.
ed25d5f is described below

commit ed25d5ff2351d20eacedc8f34b99394e79fa4398
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Mar 13 13:17:27 2021 +0100

    camel-core - Warump pooled exchange factory on doBuild so the class is loaded eager by the JVM instead of on first exchange use.
---
 .../java/org/apache/camel/impl/engine/PooledExchangeFactory.java | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
index 19c02b0..82613a3 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
@@ -37,6 +37,15 @@ public final class PooledExchangeFactory extends PrototypeExchangeFactory {
     public PooledExchangeFactory() {
     }
 
+    @Override
+    protected void doBuild() throws Exception {
+        super.doBuild();
+        // force to create and load the class during build time so the JVM does not
+        // load the class on first exchange to be created
+        DefaultPooledExchange dummy = new DefaultPooledExchange(camelContext);
+        LOG.trace("Warming up PooledExchangeFactory loaded class: {}", dummy.getClass().getName());
+    }
+
     public PooledExchangeFactory(Consumer consumer) {
         super(consumer);
     }