Reputation: 4295
I'm trying to set up a couple of tiny applications - as a demonstration of some new tooling - that communicate via ActiveMQ Artemis. Because it's just a demo, I'm trying to make things as easy as possible for the end-users. As such, I was going the route of the embedded Artemis support that Spring Boot now has.
I've got this working great. However, I can't work out how to make this also listen on a local port so that other services can connect to it as well.
Essentially what I want to do is:
I've marked the bits that I can't (yet) work out how to do.
For reference, my application.properties
is currently this:
server.port=8082
spring.artemis.mode=EMBEDDED
spring.artemis.host=localhost
spring.artemis.port=61616
spring.artemis.embedded.enabled=true
spring.jms.template.default-destination=my-queue-1
logging.level.org.apache.activemq.audit.base=DEBUG
logging.level.org.apache.activemq.audit.message=DEBUG
Is it possible to make this work? Or do I need to have people run an external Artemis service instead?
Cheers
Edit. Artemis isn't essential. It just needs to be some asynchronous messaging platform. If it can be done with ActiveMQ Classic, RabbitMQ or anything else then that's fine.
Upvotes: 2
Views: 5272
Reputation: 35152
By default Spring will only allow in-vm connections to the embedded instance of ActiveMQ Artemis. See the use of InVMAcceptorFactory
in ArtemisEmbeddedConfigurationFactory.
To change this you need to add a new Acceptor to your Artemis configuration through a custom ArtemisConfigurationCustomizer
bean, e.g.:
import org.springframework.boot.autoconfigure.jms.artemis.ArtemisConfigurationCustomizer;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ArtemisConfig implements ArtemisConfigurationCustomizer {
@Override
public void customize(org.apache.activemq.artemis.core.config.Configuration configuration) {
configuration.addAcceptorConfiguration("remote", "tcp://0.0.0.0:61616");
}
}
Upvotes: 3