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/10/02 07:57:25 UTC

[camel] branch main updated (89fb960 -> ac1cf87)

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 89fb960  CAMEL-17035: camel-core - Rest DSL - Allow to set response message quickly
     new 7c1ad85  CAMEL-17033: camel-core - Optimize Event notifiers to no longer check for started state for every events triggered.
     new 1c09663  CAMEL-17033: camel-core - Optimize Event notifiers to no longer check for started state for every events triggered.
     new ac1cf87  Polished

The 3 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:
 .../org/apache/camel/spi/ManagementStrategy.java   | 14 ++++-
 .../impl/engine/DefaultManagementStrategy.java     | 13 +++++
 .../java/org/apache/camel/support/EventHelper.java | 68 +++++++++-------------
 .../ROOT/pages/camel-3x-upgrade-guide-3_12.adoc    |  2 +
 4 files changed, 55 insertions(+), 42 deletions(-)

[camel] 02/03: CAMEL-17033: camel-core - Optimize Event notifiers to no longer check for started state for every events triggered.

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 1c09663048f265a30b438b2d5293ea7bb28847d3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Oct 2 09:50:27 2021 +0200

    CAMEL-17033: camel-core - Optimize Event notifiers to no longer check for started state for every events triggered.
---
 docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_12.adoc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_12.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_12.adoc
index 49f3812..90957f1 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_12.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_12.adoc
@@ -19,6 +19,8 @@ The `ThroughputLogger` has changed the return type from `int` to `long` in the `
 Removed the `dataSonnet(Expression)` methods from `RouteBuilder` as they should not be used;
 use the methods that take `String` as type.
 
+Added method `getStartedEventNotifiers` to `org.apache.camel.spi.ManagementStrategy`;
+
 === Data Formats
 
 We had to fix all the data-formats options that take a Java classname to support

[camel] 03/03: Polished

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 ac1cf8738618784c2c96cba7861a447d7c20dcd7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Oct 2 09:56:52 2021 +0200

    Polished
---
 .../src/main/java/org/apache/camel/spi/ManagementStrategy.java     | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementStrategy.java
index edec86d..4920afa 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementStrategy.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementStrategy.java
@@ -25,12 +25,13 @@ import org.apache.camel.StaticService;
 /**
  * Strategy for management.
  * <p/>
- * This is totally pluggable allowing to use a custom or 3rd party management implementation with Camel.
+ * If JMX is detected (camel-management JAR on the classpath) then org.apache.camel.management.JmxManagementStrategy is
+ * in use. Otherwise, the DefaultManagementStrategy is in use.
+ * <p/>
+ * You can also plugin and use a 3rd party management implementation with Camel.
  *
  * @see org.apache.camel.spi.EventNotifier
  * @see org.apache.camel.spi.EventFactory
- * @see ManagementObjectNameStrategy
- * @see org.apache.camel.spi.ManagementAgent
  */
 public interface ManagementStrategy extends StaticService {
 

[camel] 01/03: CAMEL-17033: camel-core - Optimize Event notifiers to no longer check for started state for every events triggered.

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 7c1ad8528d8555ebd95d9dacea5e26a14432aeaf
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Oct 2 09:46:18 2021 +0200

    CAMEL-17033: camel-core - Optimize Event notifiers to no longer check for started state for every events triggered.
---
 .../org/apache/camel/spi/ManagementStrategy.java   |  7 +++
 .../impl/engine/DefaultManagementStrategy.java     | 13 +++++
 .../java/org/apache/camel/support/EventHelper.java | 68 +++++++++-------------
 3 files changed, 49 insertions(+), 39 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementStrategy.java
index 0676848..edec86d 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementStrategy.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementStrategy.java
@@ -85,6 +85,13 @@ public interface ManagementStrategy extends StaticService {
     List<EventNotifier> getEventNotifiers();
 
     /**
+     * Gets all the started event notifiers, which is ready to be used.
+     *
+     * @return started event notifiers
+     */
+    List<EventNotifier> getStartedEventNotifiers();
+
+    /**
      * Adds the event notifier to use.
      * <p/>
      * Ensure the event notifier has been started if its a {@link Service}, as otherwise it would not be used.
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultManagementStrategy.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultManagementStrategy.java
index 84c4d44..9740118 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultManagementStrategy.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultManagementStrategy.java
@@ -50,6 +50,7 @@ import org.apache.camel.util.ObjectHelper;
 public class DefaultManagementStrategy extends ServiceSupport implements ManagementStrategy, CamelContextAware {
 
     private final List<EventNotifier> eventNotifiers = new CopyOnWriteArrayList<>();
+    private final List<EventNotifier> startedEventNotifiers = new CopyOnWriteArrayList<>();
     private EventFactory eventFactory = new DefaultEventFactory();
     private ManagementObjectNameStrategy managementObjectNameStrategy;
     private ManagementObjectStrategy managementObjectStrategy;
@@ -74,8 +75,17 @@ public class DefaultManagementStrategy extends ServiceSupport implements Managem
     }
 
     @Override
+    public List<EventNotifier> getStartedEventNotifiers() {
+        return startedEventNotifiers;
+    }
+
+    @Override
     public void addEventNotifier(EventNotifier eventNotifier) {
         this.eventNotifiers.add(eventNotifier);
+        if (isStarted()) {
+            // already started
+            this.startedEventNotifiers.add(eventNotifier);
+        }
         if (getCamelContext() != null) {
             // okay we have an event notifier that accepts exchange events so its applicable
             if (!eventNotifier.isIgnoreExchangeEvents()) {
@@ -86,6 +96,7 @@ public class DefaultManagementStrategy extends ServiceSupport implements Managem
 
     @Override
     public boolean removeEventNotifier(EventNotifier eventNotifier) {
+        startedEventNotifiers.remove(eventNotifier);
         return eventNotifiers.remove(eventNotifier);
     }
 
@@ -205,10 +216,12 @@ public class DefaultManagementStrategy extends ServiceSupport implements Managem
     @Override
     protected void doStart() throws Exception {
         ServiceHelper.startService(eventNotifiers, managementAgent, managementObjectStrategy, managementObjectNameStrategy);
+        startedEventNotifiers.addAll(eventNotifiers);
     }
 
     @Override
     protected void doStop() throws Exception {
+        startedEventNotifiers.clear();
         ServiceHelper.stopService(managementObjectNameStrategy, managementObjectStrategy, managementAgent, eventNotifiers);
     }
 
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/EventHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/EventHelper.java
index cdb21bb..09b5b6a 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/EventHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/EventHelper.java
@@ -25,7 +25,6 @@ import org.apache.camel.Exchange;
 import org.apache.camel.ExtendedExchange;
 import org.apache.camel.Processor;
 import org.apache.camel.Route;
-import org.apache.camel.StatefulService;
 import org.apache.camel.spi.CamelEvent;
 import org.apache.camel.spi.EventFactory;
 import org.apache.camel.spi.EventNotifier;
@@ -118,7 +117,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -157,7 +156,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -196,7 +195,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -235,7 +234,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -274,7 +273,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -313,7 +312,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -352,7 +351,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -391,7 +390,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -430,7 +429,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -469,7 +468,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -515,7 +514,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -561,7 +560,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -609,7 +608,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -657,7 +656,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -703,7 +702,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -749,7 +748,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -795,7 +794,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -841,7 +840,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -880,7 +879,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -919,7 +918,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -958,7 +957,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -997,7 +996,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -1036,7 +1035,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -1075,7 +1074,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -1114,7 +1113,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -1153,7 +1152,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -1192,7 +1191,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -1231,7 +1230,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -1270,7 +1269,7 @@ public final class EventHelper {
             return false;
         }
 
-        List<EventNotifier> notifiers = management.getEventNotifiers();
+        List<EventNotifier> notifiers = management.getStartedEventNotifiers();
         if (notifiers == null || notifiers.isEmpty()) {
             return false;
         }
@@ -1299,15 +1298,6 @@ public final class EventHelper {
     }
 
     private static boolean doNotifyEvent(EventNotifier notifier, CamelEvent event) {
-        if (notifier instanceof StatefulService) {
-            // only notify if notifier is started (when stateful service)
-            boolean started = ((StatefulService) notifier).isStarted();
-            if (!started) {
-                LOG.debug("Ignoring notifying event {}. The EventNotifier has not been started yet: {}", event, notifier);
-                return false;
-            }
-        }
-
         if (!notifier.isEnabled(event)) {
             LOG.trace("Notifier: {} is not enabled for the event: {}", notifier, event);
             return false;