lburgazzoli edited a comment on issue #1079: Example Request: 
CamelJmsToFileExample.java
URL: https://github.com/apache/camel-k/issues/1079#issuecomment-565192051
 
 
   So I have a route like:
   
   ```java
   import org.apache.camel.PropertyInject;
   import org.apache.camel.builder.RouteBuilder;
   
   public class Sample extends RouteBuilder {
     @PropertyInject("my.url")
     String url;
   
     @Override
     public void configure() throws Exception {
       from("timer:tick")
         .setBody().constant(url)
         .log("${body}");
     }
   }
   ```
   
   The I do run it with:
   
       kamel run --dev -p my.url=test examples/Sample.java
   
   And what I see in my toute is:
   
   ```
   [2] 2019-12-12 21:19:31.752 INFO  [main] ApplicationRuntime - Add listener: 
org.apache.camel.k.listener.ContextConfigurer@3c9d0b9d
   [2] 2019-12-12 21:19:31.760 INFO  [main] ApplicationRuntime - Add listener: 
org.apache.camel.k.listener.RoutesConfigurer@7ee955a8
   [2] 2019-12-12 21:19:31.763 INFO  [main] ApplicationRuntime - Add listener: 
org.apache.camel.k.listener.RoutesDumper@6ac13091
   [2] 2019-12-12 21:19:31.793 INFO  [main] RuntimeSupport - Looking up loader 
for language: java
   [2] 2019-12-12 21:19:31.805 INFO  [main] RuntimeSupport - Found loader 
org.apache.camel.k.loader.java.JavaSourceRoutesLoader@6f96c77 for language java 
from service definition
   [2] 2019-12-12 21:19:32.536 INFO  [main] RoutesConfigurer - Loading routes 
from: file:/etc/camel/sources/i-source-000/Sample.java?language=java
   [2] 2019-12-12 21:19:32.537 INFO  [main] ApplicationRuntime - Listener 
org.apache.camel.k.listener.RoutesConfigurer@7ee955a8 executed in phase 
ConfigureRoutes
   [2] 2019-12-12 21:19:32.555 INFO  [main] BaseMainSupport - Using properties 
from: file:/etc/camel/conf/application.properties
   [2] 2019-12-12 21:19:33.023 INFO  [main] ApplicationRuntime - Listener 
org.apache.camel.k.listener.ContextConfigurer@3c9d0b9d executed in phase 
ConfigureContext
   [2] 2019-12-12 21:19:33.024 INFO  [main] DefaultCamelContext - Apache Camel 
3.0.0-RC3 (CamelContext: camel-k) is starting
   [2] 2019-12-12 21:19:33.028 INFO  [main] DefaultManagementStrategy - JMX is 
disabled
   [2] 2019-12-12 21:19:33.180 INFO  [main] DefaultCamelContext - StreamCaching 
is not in use. If using streams then its recommended to enable stream caching. 
See more details at http://camel.apache.org/stream-caching.html
   [2] 2019-12-12 21:19:33.192 INFO  [main] DefaultCamelContext - Route: route1 
started and consuming from: timer://tick
   [2] 2019-12-12 21:19:33.196 INFO  [main] DefaultCamelContext - Total 1 
routes, of which 1 are started
   [2] 2019-12-12 21:19:33.199 INFO  [main] DefaultCamelContext - Apache Camel 
3.0.0-RC3 (CamelContext: camel-k) started in 0.173 seconds
   [2] 2019-12-12 21:19:33.200 INFO  [main] ApplicationRuntime - Listener 
org.apache.camel.k.listener.RoutesDumper@6ac13091 executed in phase Started
   [2] 2019-12-12 21:19:34.223 INFO  [Camel (camel-k) thread #1 - timer://tick] 
route1 - test
   [2] 2019-12-12 21:19:35.196 INFO  [Camel (camel-k) thread #1 - timer://tick] 
route1 - test
   ```
   
   So the properties binding works. I think your issue is that the connection 
factory is instantiated at class constructions, you should move it to the 
`configure` method as the injection happens after the class has been 
constructed, before that the url is null

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to