apache / camel-quarkus

Apache Camel Quarkus
https://camel.apache.org
Apache License 2.0
257 stars 191 forks source link

Camel 4.7 - Reflection in jms and sql component #6142

Open davsclaus opened 5 months ago

davsclaus commented 5 months ago

Describe the feature here

https://github.com/apache/camel/blob/main/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsServiceLocationHelper.java

https://github.com/apache/camel/blob/main/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlServiceLocationHelper.java

It is blocked by

zhfeng commented 5 months ago

@davsclaus How about if ActiveMQConnectionFactory is wrapped by such JMSPoolConnectionFactory provided by quarkus-pooled-jms ?

oscerd commented 5 months ago

@davsclaus How about if ActiveMQConnectionFactory is wrapped by such JMSPoolConnectionFactory provided by quarkus-pooled-jms ?

We should not use runtime specific dependency where possible.

zhfeng commented 5 months ago

OK, so for camel-jms we could only add jakarta.jms.ConnectionFactory to the reflection configuration in native mode. And for camel-sql adding javax.sql.DataSource?

Then if using with quarkus-pooled-jms, there might be an issue to get brokerUrl?

zhfeng commented 5 months ago

Ah, maybe we can consider to add ActiveMQConnectionFactory reflection configuration in quarkus-artemis extension?

jamesnetherton commented 5 months ago

Ah, maybe we can consider to add ActiveMQConnectionFactory reflection configuration in quarkus-artemis extension?

Can we not just use Jandex and discover all impls of ConnectionFactory & DataSource?

zhfeng commented 5 months ago

@jamesnetherton well, it looks like quarkus-artemis-jms has not included jandex yet.

jamesnetherton commented 4 months ago

I don't think this can work OOTB. The problem is that the ConnectionFactory and DataSource are synthetic ClientProxy beans. When you do reflection on them, the methods that get returned are those of the generated proxy and not the actual target type.

We could maybe investigate doing ClientProxy.unwrap before beans get returned from RuntimeBeanRepository.

zhfeng commented 2 months ago

Hi @davsclaus what version of camel jbang should be used? I run with 4.7 but there is no --address

JBang version: 0.117.1
Camel JBang version: 4.7.0
Unknown option: '--address'
Usage: camel get endpoint [-h] [--short-uri] [--watch] [--wide-uri]
                          [--filter=<filter>]
                          [--filter-direction=<filterDirection>]
                          [--filter-total=<filterTotal>] [--limit=<limit>]
                          [--sort=<sort>] [<name>]
Get usage of Camel endpoints
      [<name>]            Name or pid of running Camel integration
  -h, --help              Display the help and sub-commands
      --watch             Execute periodically and showing output fullscreen
      --sort=<sort>       Sort by pid, name, age or total
      --limit=<limit>     Filter endpoints by limiting to the given number of
                            rows
      --filter=<filter>   Filter endpoints by URI
      --filter-direction=<filterDirection>
                          Filter by direction (in or out)
      --filter-total=<filterTotal>
                          Filter endpoints that must be higher than the given
                            usage
      --short-uri         List endpoint URI without query parameters (short)
      --wide-uri          List endpoint URI in full details
davsclaus commented 2 months ago

I think we renamed it to camel get service There is a --metadata option that shows more data

zhfeng commented 2 months ago

OK, I run camel get endpoint to get

 PID   NAME     AGE   DIR  TOTAL  STUB  REMOTE  URI        
 44995  camel-1  1h2m                      x     jms://test 

but camel get service return empty result even with --metadata

davsclaus commented 2 months ago

the blog shows how it should look https://camel.apache.org/blog/2024/07/camel47-whatsnew/

davsclaus commented 2 months ago

try this example in jbang https://github.com/apache/camel-kamelets-examples/tree/main/jbang/camel-1.0

zhfeng commented 2 months ago

Thanks a lot @davsclaus !

Hmm, why there is another one?

zhfeng commented 2 months ago

Is there any way to run in a quarkus native mode?

davsclaus commented 2 months ago

there are 2 because they are IN and OUT

davsclaus commented 2 months ago

In native I guess you need to add something to that build time graal thingy as it uses reflection to get the data

zhfeng commented 2 months ago

there are 2 because they are IN and OUT

But why does it appear in quarkus runtime, in plain camel there is only one of IN?

zhfeng commented 2 months ago

In native I guess you need to add something to that build time graal thingy as it uses reflection to get the data

I see and is there any option with camel run to build it in native?

davsclaus commented 2 months ago

export to quarkus and run the quarkus native build via maven

zhfeng commented 2 months ago

@davsclaus I'm still confuse why running with the same Java file, there is a different output of camel get service between the plain camel and quarkus runtime?

zhfeng commented 2 months ago

@davsclaus if setting camel.main.endpoint-runtime-statistics-enabled=true, there will be only one IN result with camel get service when running with quarkus.

I found the following codes which might be related https://github.com/apache/camel/blob/main/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultEndpointServiceRegistry.java#L93-L99

So @jamesnetherton does it make sense to default enable endpoint-runtime-statistics in camel-quarkus-cli-connector ?

Also I create https://issues.apache.org/jira/browse/CAMEL-21163

For native support, it looks like even camel-quarkus-cli-connector is only JVM support right now. So not sure if we can get it working in native.

davsclaus commented 2 months ago

you see all this extra stats in camel-jbang as it runs camel in dev mode that turn on various stuff. For production mode, then its expected to not see these information from this CLI.

Its a CLI for development / troubleshooting etc.

See ProfileConfigurer in camel-main

davsclaus commented 2 months ago

So maybe what quarkus need is that if you use mvn quarkus:dev then it runs in developer mode, and set this on camel

camelContext.getCamelContextExtension().setProfile("dev");
jamesnetherton commented 2 months ago

So maybe what quarkus need is that if you use mvn quarkus:dev then it runs in developer mode

Which unfortunately is broken until we get Camel 4.8.0. https://github.com/apache/camel-quarkus/issues/6083.

zhfeng commented 2 months ago

Ha, thanks @jamesnetherton and I will check it again when 4.8.0 is out.

zhfeng commented 2 months ago

@davsclaus

you see all this extra stats in camel-jbang as it runs camel in dev mode that turn on various stuff. For production mode, then its expected to not see these information from this CLI.

Its a CLI for development / troubleshooting etc.

IIUC, only when I uses camel run MyRouteBuilder.java --dev, these extra stats can be returned by camel get service?

If I run in production like camel run MyRouteBuilder.java --profile=prod, them should not be listed. Is it right?

But I test with --profile=prod, them are still be listed.

davsclaus commented 2 months ago

its only when you have those extra stats you can know for sure if its only IN or OUT - if no stats then you just have both.