spring-bootactivemq-classicactivemq-artemis

ActiveMQ Artemis vs ActiveMQ Classic connection


Is there any difference between ActiveMQ Artemis connection configuration between aplication.yaml:

spring.artemis.mode=native
spring.artemis.host=192.168.1.210
spring.artemis.port=9876

vs

spring.activemq.broker-url=tcp://192.168.1.210:9876
spring.activemq.user=admin
spring.activemq.password=secret

If you use only this dependency:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-artemis</artifactId>
        </dependency>

I assume that spring-boot-starter-artemis allows you to connect via JMS, and that is spring.activemq.XXX, and if you want to connect in the Artemis approach then you use spring.artemis.XXX the bean will autocofigure.

But I am not sure

I read the key differences on this page.

Which one is better? For JMS (ActiveMQConnectionFactory) I can use CachingConnectionFactory, is it needed for artemis auto-configuration?


Solution

  • If you're using spring-boot-starter-artemis that indicates you want to connect to an instance of ActiveMQ Artemis which means you'll want to configure spring.artemis.XXX properties. Assuming you're using spring-boot-starter-artemis 2.7.0 (i.e. the latest) you'll want to use spring.activemq.broker-url as referenced in the Spring documentation, e.g.:

    spring.artemis.mode=native
    spring.artemis.broker-url=tcp://192.168.1.210:9876
    spring.artemis.user=admin
    spring.artemis.password=secret
    

    The host and port properties you referenced were deprecated in favor of broker-url awhile back.

    The documentation continues:

    By default, a CachingConnectionFactory wraps the native ConnectionFactory with sensible settings that you can control by external configuration properties in spring.jms.*:

    spring.jms.cache.session-cache-size=5
    

    If you’d rather use native pooling, you can do so by adding a dependency to org.messaginghub:pooled-jms and configuring the JmsPoolConnectionFactory accordingly, as shown in the following example:

    spring.artemis.pool.enabled=true
    spring.artemis.pool.max-connections=50
    

    Whether you use spring-boot-starter-artemis with spring.artemis.XXX properties or spring-boot-starter-activemq with spring.activemq.XXX properties the underlying Spring components will use JMS to connect.