-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AMQP connection factory injection example improvement #1961
Comments
@astefanutti is correct that the ConnectionFactory typically does not need to be created manually like in the snippet above. Passing If you really need to create the ConnectionFactory manually, then CDI and MicroProfile Config is the way to go on Quarkus: // 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");
}
} |
@ppalaga please be aware that cdi does not work in camel-k |
Oh |
@astefanutti I think in the latest camel release lookup by type should work if the component option has the right annotations |
Thanks @lburgazzoli, I'll try it asap. |
This issue has been automatically marked as stale due to 90 days of inactivity. |
From the following example, taken from https://github.com/keunlee/camel-k-starter-workbench:
It could be improved if:
quarkus.qpid-jms.url
in theapplication.properties
file, to leverage auto-configuration and lookup of the connection factory.The text was updated successfully, but these errors were encountered: