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 42f53fc  camel-core - Optimize SendProcessor to only use counter if 
extended stats is enabled.
42f53fc is described below

commit 42f53fc0bfe5bf6704d19833f1895a225af29911
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Mon Mar 15 06:56:11 2021 +0100

    camel-core - Optimize SendProcessor to only use counter if extended stats 
is enabled.
---
 .../java/org/apache/camel/processor/SendProcessor.java     | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/SendProcessor.java
 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/SendProcessor.java
index 784d28e..e76b002 100644
--- 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/SendProcessor.java
+++ 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/SendProcessor.java
@@ -59,6 +59,7 @@ public class SendProcessor extends AsyncProcessorSupport 
implements Traceable, E
     protected ExchangePattern destinationExchangePattern;
     protected String id;
     protected String routeId;
+    protected boolean extendedStatistics;
     protected final AtomicLong counter = new AtomicLong();
 
     public SendProcessor(Endpoint destination) {
@@ -124,11 +125,12 @@ public class SendProcessor extends AsyncProcessorSupport 
implements Traceable, E
         // if you want to permanently to change the MEP then use 
.setExchangePattern in the DSL
         final ExchangePattern existingPattern = exchange.getPattern();
 
-        counter.incrementAndGet();
+        if (extendedStatistics) {
+            counter.incrementAndGet();
+        }
 
         // if we have a producer then use that as its optimized
         if (producer != null) {
-
             final Exchange target = exchange;
             // we can send with a different MEP pattern
             if (destinationExchangePattern != null || pattern != null) {
@@ -213,6 +215,14 @@ public class SendProcessor extends AsyncProcessorSupport 
implements Traceable, E
 
     @Override
     protected void doInit() throws Exception {
+        // only if JMX is enabled
+        if (camelContext.getManagementStrategy() != null && 
camelContext.getManagementStrategy().getManagementAgent() != null) {
+            this.extendedStatistics
+                    = 
camelContext.getManagementStrategy().getManagementAgent().getStatisticsLevel().isExtended();
+        } else {
+            this.extendedStatistics = false;
+        }
+
         // if the producer is not singleton we need to use a producer cache
         if (!destination.isSingletonProducer() && producerCache == null) {
             // use a single producer cache as we need to only hold reference 
for one destination

Reply via email to