Tech stack and tech notes:

  • Spring-boot: 2.3.1.RELEASE
  • Camel: 3.4.1
  • Artemis: 2.11.0
  • Artemis has been setup to use a user name and password(artemis/artemis).
  • Using org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory for connection factory.

Summary Of Issue:

When using a bean to configure the Camel JMS component actuator fails with an invalid user name and password. The user name and password is correct and once the camel route starts I can produce and consume messages on the Artemis broker, however actuator keeps on failing. See this stackoverflow question for a lot more details.

I have attached a small application cluster-producer.zip which reproduces the problem. I am using the following Artemis docker image which has security enabled by default.

My docker-compose file:

version: '3.3'
services:
  artemis-jms:
    image: vromero/activemq-artemis
    container_name:  artemis-jms
    ports:
      - "8161:8161"
      - "61616:61616"
    environment:
      - ARTEMIS_USERNAME=artemis
      - ARTEMIS_PASSWORD=artemis

Steps to reproduce

  1. Run the docker image using the docker-compose file.
  2. Run the application

The following is in the error logs:

2020-08-13 09:42:51.659  WARN 18955 --- [)-192.168.1.158] o.s.boot.actuate.jms.JmsHealthIndicator  : JMS health check failed

javax.jms.JMSSecurityException: AMQ229031: Unable to validate user from /127.0.0.1:51874. Username: null; SSL certificate subject DN: unavailable
    at org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:467) ~[artemis-core-client-2.12.0.jar:2.12.0]
    at org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:361) ~[artemis-core-client-2.12.0.jar:2.12.0]
    at org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQClientProtocolManager.createSessionContext(ActiveMQClientProtocolManager.java:300) ~[artemis-core-client-2.12.0.jar:2.12.0]

Calling actuator:

  "jms": {
            "status": "DOWN",
            "details": {
                "error": "javax.jms.JMSSecurityException: AMQ229031: Unable to validate user from /127.0.0.1:54662. Username: null; SSL certificate subject DN: unavailable"
            }
        },

Feel free to reach out if there are any further details required.

Comment From: wilkinsona

Spring Boot's JMS health indicator uses a ConnectionFactory to connect to the broker and determine its health. You've only defined a JmsComponent bean that is Camel-specific and which Spring Boot knows nothing about. As a result, Spring Boot is auto-configuring a connection factory for you using its defaults. If you want its JMS auto-configuration to back of and use your own ConnectionFactory you should define it as a bean. This will allow it to be consumed by the JMS health indicator and connect to the broker using the username and password that you've configured.

Comment From: Namphibian

@wilkinsona big thanks for that. I am moving all of our stuff from XML config and falsely assumed the connection factory created in the jms component would be used. Got it working with an extra 3 lines of code. Appreciate the feedback.