Skip to content
Advertisement

ActiveMQ Artemis prefixes “jms.topic.” to all topic names defined on Spring Boot Client

I’m using ActiveMQ Artemis 2.18.0 and version 2.5.5 of the spring-boot-starter-artemis dependency on a Spring Boot client. In my use case clients are required to communicate with each other via topics. The issue is that the string jms.topic. is getting prefixed to every topic defined on the client. For example the topic foo.sendInfo becomes jms.topic.foo.sendInfo.

The broker.xml file is as shown below. The acceptor used by the Spring Boot client is the netty-ssl-acceptor on port 61617.

JavaScript

The connection factory on the Spring Boot client is configured as shown below.

JavaScript

Below is the POM file, with only the relevant dependencies.

JavaScript

The below code snippet shows a producer that publishes to the topic server.weatherForecast and a consumer that subscribes to the same topic. Messages are exchanged, without issue, between this producer and consumer as jms.topic. is prefixed to every topic defined on the Spring Boot client. However, when I use an external tool to subscribe to MQTT messages, messages are not received on the topic defined on the tool unless the topic being subscribed to is changed from server.weatherForecast to jms.topic.server.weatherForecast.

JavaScript

Upon enabling TRACE logging for the RemotingConnectionImpl, I saw that in the CreateSessionResponseMessage, the serverVersion attribute had a value of 131, and in the CreateSessionMessage, the version attribute had a value of 127.

How do I ensure that jms.topic. is not prefixed to topic names?

A minimal reproducible example can be downloaded from this GitHub repository. I tried to log the prefix in the code, but didn’t find any means of doing so, all the logs simply showed the topic name without the prefix. However, subscribing to the topic being published to from an external client should indicate the prefixing. On subscribing to topicName and jms.topic.topicName, it will be evident that the message will be delivered to the latter. I’ve noticed that some clients parse the “.” as a “/”, so that could be something else to try in case the “.” doesn’t work.

Advertisement

Answer

I took your reproducer and I managed to re-create the problem you’re seeing where the client is using jms.topic.test.topic. However, once I added multicastPrefix=jms.topic. to the “artemis” acceptor in broker.xml the problem went away. The broker now strips the client’s prefix and uses test.topic instead.

You did have multicastPrefix=jms.topic. set on the “netty-ssl-acceptor” acceptor, but your client wasn’t actually using that acceptor.

I also ran mvn dependency:tree to see why your application is using the ActiveMQ Artemis 1.3.0 client. This is what it output (in part):

JavaScript

So it appears that the dependency on org.apache.activemq:artemis-jms-client:jar:1.3.0 is coming directly from org.springframework.boot:spring-boot-starter-artemis:jar:2.5.5 which is really strange since it has clearly defined a dependency on org.apache.activemq:artemis-jms-client:jar:2.17.0. However, if I change the <parent> to use 2.5.5 instead of 1.4.1.RELEASE the problem goes away, e.g.:

JavaScript

This is what mvn dependency:tree outputs now (in part):

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement