-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Enhance Artemis jms auto configuration #10739
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
Comments
Looking at the Artemis code, it doesn't appear to be possible to construct a connection factory with a URL without losing some control over the transport configuration. Currently, we explicitly configure the use of Unless there's a way that can please everyone, I'm leaning towards this not be supported by auto-configuration. @pax95 There's a very good chance that you know more about configuring Artermis than I do, perhaps you can guide us towards a way that will work? |
It seems that the transport configuration actually makes use of NettyConnectorFactory when constructing the connection factory from a URL. Small sample with a Camel route: @ConfigurationProperties(prefix = "spring.artemis")
public class AmqConfig {
private String url;
@Bean("connectionFactory")
public ConnectionFactory connectionFactory() {
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(this.url);
LOG.info("cf info {}", cf);
return cf;
}
public void setUrl(String url) {
this.url = url;
}
}
@Component
class MyRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("jms:foo?connectionFactory=#connectionFactory").transacted().log("log recieved");
from("timer:bar").setBody(constant("the message")).transacted().log("sending").to("jms:foo?connectionFactory=#connectionFactory");
}
} The log statement when setting the property
I will push the sample to GitHub later. |
@wilkinsona Pushed a small example here https://github.com/pax95/activemq-test |
A url property is going to get a bit messy when coupled with the existing host and port properties. We have that elsewhere though and have managed to deal with it. |
agreed. Thats why I wanted to hear your opinion. Btw the Activemq auto configuration actually has a brokerUrl property too. |
@pax95 Agree with you. @wilkinsona I think the
The BTW, I implemented a customized import org.apache.activemq.artemis.uri.ConnectionFactoryParser;
...
public ConnectionFactory connectionFactory() throws Exception {
ConnectionFactoryParser parser = new ConnectionFactoryParser();
return parser.newObject(parser.expandURI(artemisProperties.getUri()), "someCFConfig");
} |
As a developer on ActiveMQ Artemis I would recommend using a URL instead host:port. It's easy to construct an Artemis connection factory using a URL. Just use this constructor - |
Thanks for the follow-up @jbertram. What would be your recommendation regarding what @wilkinsona pointed above. We may need to tune |
The URL replaces manual configuration of the |
Same issue on our project. |
Really interested in this feature as well. |
I am interested as well. It's easy to setup a ConnectionFactory like @jbertram specified, but it would be nice to have the option. |
FYI, I just sent #24302 to implement this functionality. |
Closing in favor of PR #24302 |
Currently you can only auto configure a single broker using the host and port options.
It seems not possible to set other cluster or ha attributes on the auto create
ActiveMQConnectionFactory
that is created without ha enabled.It would be nice if you could use auto configuration to configure those options as well. Maybe expose a new property = url that could be used to construct the ActiveMQConnectionFactory
In that way you could set the url property in the configuration to e.g.
spring.artemis.url=(tcp://localhost:61616,tcp://localhost:61716)?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1
The text was updated successfully, but these errors were encountered: