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

davsclaus pushed a commit to branch rcmd
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b5a11fa3418e3a5e11b24955133dfb72723cb227
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Oct 10 11:52:06 2024 +0200

    CAMEL-21193: camel-jbang - Add listen command
---
 .../camel/impl/console/ReceiveDevConsole.java      | 34 +++++++++++++---------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git 
a/core/camel-console/src/main/java/org/apache/camel/impl/console/ReceiveDevConsole.java
 
b/core/camel-console/src/main/java/org/apache/camel/impl/console/ReceiveDevConsole.java
index aed1721b1be..c9a7e291cd6 100644
--- 
a/core/camel-console/src/main/java/org/apache/camel/impl/console/ReceiveDevConsole.java
+++ 
b/core/camel-console/src/main/java/org/apache/camel/impl/console/ReceiveDevConsole.java
@@ -228,20 +228,28 @@ public class ReceiveDevConsole extends AbstractDevConsole 
{
                     ObjectName query = ObjectName.getInstance(
                             jmxDomain + ":context=" + prefix + 
getCamelContext().getManagementName() + ",type=producers,*");
                     Set<ObjectName> set = mbeanServer.queryNames(query, null);
-                    for (ObjectName on : set) {
-                        String uri = (String) mbeanServer.getAttribute(on, 
"EndpointUri");
-                        if (PatternHelper.matchPattern(uri, endpoint)) {
-                            // is the endpoint able to create a consumer
-                            target = getCamelContext().getEndpoint(uri);
-                            // is the target able to create a consumer
-                            org.apache.camel.spi.UriEndpoint ann = 
ObjectHelper.getAnnotationDeep(target, org.apache.camel.spi.UriEndpoint.class);
-                            if (ann != null) {
-                                if (ann.producerOnly()) {
-                                    target = null;
+                    if (set != null && !set.isEmpty()) {
+                        for (ObjectName on : set) {
+                            String uri = (String) mbeanServer.getAttribute(on, 
"EndpointUri");
+                            if (PatternHelper.matchPattern(uri, endpoint)) {
+                                // is the endpoint able to create a consumer
+                                target = getCamelContext().getEndpoint(uri);
+                                // is the target able to create a consumer
+                                org.apache.camel.spi.UriEndpoint ann
+                                        = 
ObjectHelper.getAnnotationDeep(target, org.apache.camel.spi.UriEndpoint.class);
+                                if (ann != null) {
+                                    if (ann.producerOnly()) {
+                                        // skip if the endpoint cannot consume 
(we need to be able to consume to receive)
+                                        target = null;
+                                    }
+                                    if ("*".equals(endpoint) && !ann.remote()) 
{
+                                        // skip internal when matching 
everything
+                                        target = null;
+                                    }
+                                }
+                                if (target != null) {
+                                    break;
                                 }
-                            }
-                            if (target != null) {
-                                break;
                             }
                         }
                     }

Reply via email to