You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/02/27 17:33:29 UTC

[camel] branch main updated: CAMEL-19060 (camel-seda): cache queue reference to avoid costly operations in the hot path

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

orpiske 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 23542fc5b65 CAMEL-19060 (camel-seda): cache queue reference to avoid costly operations in the hot path
23542fc5b65 is described below

commit 23542fc5b65f33cde0f74f71876fe80d8c8c853f
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Feb 9 17:49:52 2023 +0100

    CAMEL-19060 (camel-seda): cache queue reference to avoid costly operations in the hot path
---
 .../org/apache/camel/component/seda/SedaEndpoint.java   | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java b/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
index a69cbf3ac2e..296e67c0071 100644
--- a/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
+++ b/components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaEndpoint.java
@@ -100,6 +100,7 @@ public class SedaEndpoint extends DefaultEndpoint implements AsyncEndpoint, Brow
     private boolean discardIfNoConsumers;
 
     private BlockingQueueFactory<Exchange> queueFactory;
+    private volatile QueueReference ref;
 
     public SedaEndpoint() {
         queueFactory = new LinkedBlockingQueueFactory<>();
@@ -207,14 +208,22 @@ public class SedaEndpoint extends DefaultEndpoint implements AsyncEndpoint, Brow
         }
     }
 
+    @Override
+    public void start() {
+        super.start();
+
+        final String key = getComponent().getQueueKey(getEndpointUri());
+        if (ref == null) {
+            ref = getComponent().getQueueReference(key);
+        }
+    }
+
     /**
-     * Get's the {@link QueueReference} for the this endpoint.
+     * Gets the {@link QueueReference} for this endpoint.
      *
      * @return the reference, or <tt>null</tt> if no queue reference exists.
      */
-    public synchronized QueueReference getQueueReference() {
-        String key = getComponent().getQueueKey(getEndpointUri());
-        QueueReference ref = getComponent().getQueueReference(key);
+    public QueueReference getQueueReference() {
         return ref;
     }