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

orpiske pushed a commit to branch camel-4.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.0.x by this push:
     new 5143b9b6db3 CAMEL-19842: fix not creating/refreshing seda queues 
(#11331) (#11335)
5143b9b6db3 is described below

commit 5143b9b6db32241706d26f0e1fbae7f716248ce1
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Fri Sep 8 12:02:31 2023 +0200

    CAMEL-19842: fix not creating/refreshing seda queues (#11331) (#11335)
    
    - Removing the cached queue references caused a regression in 
camel-zookeeper-master. This brings back the cached references (reverts: 
d66469d6ac7243f0ae790c41a500965b885d3180)
    - Avoid keeping cached stalled references (ref: CAMEL-19815)
---
 .../apache/camel/component/seda/SedaEndpoint.java  | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 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 116424dfe30..8bba9ea9b9b 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
@@ -101,6 +101,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<>();
@@ -214,11 +215,21 @@ public class SedaEndpoint extends DefaultEndpoint 
implements AsyncEndpoint, Brow
      * @return the reference, or <tt>null</tt> if no queue reference exists.
      */
     public QueueReference getQueueReference() {
-        String key = getComponent().getQueueKey(getEndpointUri());
+        if (ref == null || ref.getCount() == 0) {
+            ref = tryQueueRefInit();
+        }
+
+        return ref;
+    }
 
-        synchronized (this) {
-            return getComponent().getQueueReference(key);
+    private QueueReference tryQueueRefInit() {
+        final SedaComponent component = getComponent();
+        if (component != null) {
+            final String key = component.getQueueKey(getEndpointUri());
+            return component.getQueueReference(key);
         }
+
+        return null;
     }
 
 
@@ -538,6 +549,8 @@ public class SedaEndpoint extends DefaultEndpoint 
implements AsyncEndpoint, Brow
         if (queue == null) {
             queue = getQueue();
         }
+
+        ref = tryQueueRefInit();
     }
 
     @Override
@@ -547,6 +560,8 @@ public class SedaEndpoint extends DefaultEndpoint 
implements AsyncEndpoint, Brow
         } else {
             LOG.debug("There is still active consumers.");
         }
+
+        ref = null;
     }
 
     @Override
@@ -578,6 +593,7 @@ public class SedaEndpoint extends DefaultEndpoint 
implements AsyncEndpoint, Brow
 
         // clear queue, as we are shutdown, so if re-created then the queue 
must be updated
         queue = null;
+        ref = null;
     }
 
 

Reply via email to