You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/01/29 16:59:36 UTC

[GitHub] [camel-k] astefanutti opened a new issue #1961: AMQP connection factory injection example improvement

astefanutti opened a new issue #1961:
URL: https://github.com/apache/camel-k/issues/1961


   From the following example:
   
   ```java
   // camel-k: language=java property-file=application.properties
   // camel-k: dependency=github:keunlee:camel-k-starter-workbench
   
   import org.apache.camel.BindToRegistry;
   import org.apache.camel.PropertyInject;
   import org.apache.camel.builder.RouteBuilder;
   import org.slf4j.Logger;
   import org.slf4j.LoggerFactory;
   import org.apache.qpid.jms.JmsConnectionFactory;
   
   public class HelloToAmqp extends RouteBuilder {
       private static final Logger LOG = LoggerFactory.getLogger(HelloToAmqp.class);
   
       @PropertyInject("messaging.broker.url.amqp")
       String messagingBrokerUrl;
   
       @BindToRegistry
       public JmsConnectionFactory connectionFactory() throws Exception {
           return new JmsConnectionFactory(messagingBrokerUrl);
       }
   
       @Override
       public void configure() throws Exception {
           from("timer:refresh?period=5000&fixedRate=true")
           .setBody()
           .simple("Hello World ${header.firedTime}")
           .log("${body}")
           .to("amqp:topic:example?exchangePattern=InOnly&connectionFactory=connectionFactory");
       }
   }
   ```
   
   It could be improved if:
   * Lookup by type of the connection factory would work
   * Remove the property injection and the connection factory method altogether, and simply pass `quarkus.qpid-jms.url` in the `application.properties` file.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k] github-actions[bot] closed issue #1961: AMQP connection factory injection example improvement

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #1961:
URL: https://github.com/apache/camel-k/issues/1961


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-k] lburgazzoli edited a comment on issue #1961: AMQP connection factory injection example improvement

Posted by GitBox <gi...@apache.org>.
lburgazzoli edited a comment on issue #1961:
URL: https://github.com/apache/camel-k/issues/1961#issuecomment-769932970


   @ppalaga please be aware that cdi does not work in camel-k
    maybe we could try to make it working


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k] lburgazzoli commented on issue #1961: AMQP connection factory injection example improvement

Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #1961:
URL: https://github.com/apache/camel-k/issues/1961#issuecomment-770934032


   @astefanutti I think in the latest camel release lookup by type should work of the component option has the right annotations


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k] lburgazzoli edited a comment on issue #1961: AMQP connection factory injection example improvement

Posted by GitBox <gi...@apache.org>.
lburgazzoli edited a comment on issue #1961:
URL: https://github.com/apache/camel-k/issues/1961#issuecomment-770934032


   @astefanutti I think in the latest camel release lookup by type should work if the component option has the right annotations


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k] ppalaga commented on issue #1961: AMQP connection factory injection example improvement

Posted by GitBox <gi...@apache.org>.
ppalaga commented on issue #1961:
URL: https://github.com/apache/camel-k/issues/1961#issuecomment-769933234


   > @ppalaga please be aware that cdi does not work in camel-k
   
   Oh


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k] astefanutti commented on issue #1961: AMQP connection factory injection example improvement

Posted by GitBox <gi...@apache.org>.
astefanutti commented on issue #1961:
URL: https://github.com/apache/camel-k/issues/1961#issuecomment-771460675


   Thanks @lburgazzoli, I'll try it asap.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k] astefanutti commented on issue #1961: AMQP connection factory injection example improvement

Posted by GitBox <gi...@apache.org>.
astefanutti commented on issue #1961:
URL: https://github.com/apache/camel-k/issues/1961#issuecomment-771460675


   Thanks @lburgazzoli, I'll try it asap.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k] ppalaga commented on issue #1961: AMQP connection factory injection example improvement

Posted by GitBox <gi...@apache.org>.
ppalaga commented on issue #1961:
URL: https://github.com/apache/camel-k/issues/1961#issuecomment-769930155


   @astefanutti is correct that the ConnectionFactory typically does not need to be created manually like in the snippet above. Passing `quarkus.qpid-jms.url`, `quarkus.qpid-jms.username` and `quarkus.qpid-jms.password` either via application.properties or via env vars/secrets `QUARKUS_QPID_JMS_URL`, etc. is simpler. See  https://camel.apache.org/camel-quarkus/latest/reference/extensions/amqp.html#_additional_camel_quarkus_configuration and https://github.com/amqphub/quarkus-qpid-jms#configuration
   
   If you really need to create the ConnectionFactory manually, then CDI and MicroProfile Config is the way to go on Quarkus:
   
   ```java
   // camel-k: language=java property-file=application.properties
   // camel-k: dependency=github:keunlee:camel-k-starter-workbench
   
   import org.apache.camel.BindToRegistry;
   import org.apache.camel.PropertyInject;
   import org.apache.camel.builder.RouteBuilder;
   import org.slf4j.Logger;
   import org.slf4j.LoggerFactory;
   import org.apache.qpid.jms.JmsConnectionFactory;
   
   public class HelloToAmqp extends RouteBuilder {
       private static final Logger LOG = LoggerFactory.getLogger(HelloToAmqp.class);
   
       @org.eclipse.microprofile.config.inject.ConfigProperty("messaging.broker.url.amqp")
       String messagingBrokerUrl;
   
       @javax.enterprise.inject.Produces
       @javax.inject.Named("connectionFactory")
       public JmsConnectionFactory connectionFactory() throws Exception {
           return new JmsConnectionFactory(messagingBrokerUrl);
       }
   
       @Override
       public void configure() throws Exception {
           from("timer:refresh?period=5000&fixedRate=true")
           .setBody()
           .simple("Hello World ${header.firedTime}")
           .log("${body}")
           .to("amqp:topic:example?exchangePattern=InOnly&connectionFactory=connectionFactory");
       }
   }
   ```


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k] lburgazzoli commented on issue #1961: AMQP connection factory injection example improvement

Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #1961:
URL: https://github.com/apache/camel-k/issues/1961#issuecomment-769932970


   @ppalaga please be aware that cdi does not work in camel-k
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [camel-k] github-actions[bot] commented on issue #1961: AMQP connection factory injection example improvement

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #1961:
URL: https://github.com/apache/camel-k/issues/1961#issuecomment-994157583


   This issue has been automatically marked as stale due to 90 days of inactivity. 
   It will be closed if no further activity occurs within 15 days.
   If you think that’s incorrect or the issue should never stale, please simply write any comment.
   Thanks for your contributions!


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org