ActiveMQ Artemis and broker URI

3k Views Asked by At

I have a Spring Framework config file

<?xml version="1.0" encoding="UTF-8"?>
<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:amq="http://activemq.apache.org/schema/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.15.12.xsd">

    <amq:queue id="testRequestQueue" physicalName="test.storm.in.request.queue" />

    <amq:connectionFactory id="jmsConnectionFactory" brokerURL="failover:(tcp://localhost:61616)?retryInterval=1000&amp;retryIntervalMultiplier=1.5&amp;maxRetryInterval=60000&amp;maxReconnectAttempts=1000" />

</beans>

However, when I run on the Storm cluster I get an error saying:

Caused by: java.lang.IllegalArgumentException: Invalid connect parameters: {retryIntervalMultiplier=1.5, maxRetryInterval=60000, retryInterval=1000}

Documentation is very confusing. I'm not sure if ActiveMQ and ActiveMQ Artemis configuration is the same or similar. I have no idea how to configure the broker uri for Apache ActiveMQ Artemis.

So my question is what I'm doing wrong?

Here's my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>itvs_pletra_imaps_test1_pagal_schema</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <maven.compiler.plugin>3.8.1</maven.compiler.plugin>
        <maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
        <maven-war-plugin.version>3.3.1</maven-war-plugin.version>
        <javee-api.version>8.0.1</javee-api.version>
        <reactive-streams.version>1.0.3</reactive-streams.version>
        <spring-web-and-context.version>5.2.9.RELEASE</spring-web-and-context.version>
        <httpclient.version>4.5.12</httpclient.version>
        <jaxb-api.version>2.4.0-b180830.0359</jaxb-api.version>
        <hibernate-core.version>5.3.0.Final</hibernate-core.version>
        <mockito-junit-jupiter.version>3.5.10</mockito-junit-jupiter.version>
        <junit-jupiter-api.version>5.7.0</junit-jupiter-api.version>
        <junit-jupiter-params.version>5.7.0</junit-jupiter-params.version>
        <slf4j-api.version>2.0.0-alpha1</slf4j-api.version>
        <log4j-core.version>2.13.3</log4j-core.version>
        <log4j-slf4j-impl.version>2.13.3</log4j-slf4j-impl.version>
        <cxf-rt-frontend-jaxws.version>3.3.6</cxf-rt-frontend-jaxws.version>
        <cxf.version>3.4.0</cxf.version>
        <maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
        <maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
        <storm-core.version>2.2.0</storm-core.version>
        <storm-client.version>2.2.0</storm-client.version>
        <storm-jms.version>2.2.0</storm-jms.version>
        <activemq-spring.version>5.16.0</activemq-spring.version>
        <javax.jms-api.version>2.0.1</javax.jms-api.version>
        <artemis-spring-integration.version>2.15.0</artemis-spring-integration.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>${jaxb-api.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-jms-examples</artifactId>
            <version>${storm-core.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.jms</groupId>
            <artifactId>javax.jms-api</artifactId>
            <version>${javax.jms-api.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>apache-artemis</artifactId>
            <version>2.15.0</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring-web-and-context.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-spring</artifactId>
            <version>${activemq-spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>artemis-spring-integration</artifactId>
            <version>2.15.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xbean</groupId>
            <artifactId>xbean-spring</artifactId>
            <version>4.18</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf-rt-frontend-jaxws.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-core</artifactId>
            <version>${storm-core.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-slf4j-impl</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-jms</artifactId>
            <version>${storm-jms.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-slf4j-impl</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-client</artifactId>
            <version>${storm-client.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <!-- declare the exclusion here -->
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-core</artifactId>
                </exclusion>
                <exclusion>
                    <!-- declare the exclusion here -->
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <!-- declare the exclusion here -->
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <!-- declare the exclusion here -->
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-slf4j-impl</artifactId>
                </exclusion>
                <exclusion>
                    <!-- declare the exclusion here -->
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.reactivestreams</groupId>
            <artifactId>reactive-streams</artifactId>
            <version>${reactive-streams.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j-api.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>${httpclient.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j-core.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>${log4j-slf4j-impl.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.ws</groupId>
            <artifactId>jbossws-api</artifactId>
            <version>1.1.2.Final</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>${javee-api.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate-core.version}</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junit-jupiter-params.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit-jupiter-api.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>${mockito-junit-jupiter.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
1

There are 1 best solutions below

3
On BEST ANSWER

The URI depends 100% on the client you're using. The ActiveMQ 5.x JMS client implementation is different from the ActiveMQ Artemis JMS client implementation. In fact they use completely different protocols under the covers (i.e. OpenWire for 5.x and "core" for Artemis).

It's not clear from your Spring configuration which client you're using. Furthermore, it's not clear from your pom.xml which client you're using either since you've defined both 5.x and Artemis dependencies, e.g.:

...
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>apache-artemis</artifactId>
    <version>2.15.0</version>
    <type>pom</type>
</dependency>
...
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-spring</artifactId>
    <version>${activemq-spring.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>artemis-spring-integration</artifactId>
    <version>2.15.0</version>
</dependency>
...

However, the exception message you're receiving (i.e. "Invalid connect parameters") indicates you're using the ActiveMQ 5.x OpenWire JMS client. Unfortunately you're using parameters that are meant for the ActiveMQ Artemis JMS client (i.e. retryIntervalMultiplier=1.5, maxRetryInterval=60000, retryInterval=1000).

Therefore, you either need to change your project so that you using the ActiveMQ Artemis JMS client or remove those improper parameters.

To be clear, the client URL parameters documented in the ActiveMQ Artemis User Manual are specifically for the ActiveMQ Artemis JMS or core client. You can find parameters for the ActiveMQ 5.x client here.

If you want to use ActiveMQ Artemis resources in your Spring config you can use something like this:

<bean id="jmsConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory">
   <property name="brokerURL" value="tcp://localhost:61616?ha=true&amp;retryInterval=1000&amp;retryIntervalMultiplier=1.5&amp;maxRetryInterval=60000&amp;maxReconnectAttempts=1000"/>
</bean>

<bean id="testRequestQueue" class="org.apache.activemq.artemis.jms.client.ActiveMQQueue">
   <constructor-arg index="0" value="test.storm.in.request.queue"/>
</bean>

After that you can remove any ActiveMQ 5.x dependencies from your pom.xml as well as xmlns:amq="activemq.apache.org/schema/core" from your Spring config.