I am building a simple application try the Artemis ActiveMQ embedded server with springboot.
Now in IntelliJ I am able to click on maven clean install and it runs fine. I am also able to start the application with no issues when i run it by running the ManagementApplication which is annotated with the @SpringBoot
annotation.
But the problem occurs when I use the commands mvn clean install
or mvn spring-boot:run
the terminal (intellij terminal or any terminal).
The tests CreateGroupListenerTest and DeleteGroupListenerTest both fail with the following error. The embedded server does not seem to be starting before the message is sent using jmsTemplate.send
. When I run the tests in Intellij they work fine. The only problem is with
I tried a multiple of things like creating a separate application.properties in test/resources directory and adding the following :
spring.artemis.embedded.enabled=true
spring.artemis.embedded.queues=group.events.queue
spring.artemis.embedded.persistent=false
logging.level.apache.activemq.artemis=DEBUG
logging.level.springframework.jms=DEBUG
# Disable the native libaio requirement
artemis.native.lib=false
But it does not work. I want to really run it using mvn spring-boot:run
. How do i get that working ?
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.228 s <<< FAILURE! -- in com.hospital.management.consumer.DeleteGroupListenerTest [ERROR] com.hospital.management.consumer.DeleteGroupListenerTest.testReceiveDeleteMessage
-- Time elapsed: 0.003 s <<< ERROR! .springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ219007: Cannot connect to server(s). Tried with all available servers.]
at .springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:309)
at .springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:199)
at .springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:533)
at .springframework.jms.core.JmsTemplate.send(JmsTemplate.java:610)
at com.hospital.management.consumer.DeleteGroupListenerTest.testReceiveDeleteMessage(DeleteGroupListenerTest.java:50)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1597) Caused by: jakarta.jms.JMSException: Failed to create session factory
at .apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:912)
at .apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:311)
at .apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:306)
at .springframework.jms.connection.SingleConnectionFactory.doCreateConnection(SingleConnectionFactory.java:475)
at .springframework.jms.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:434)
at .springframework.jms.connection.SingleConnectionFactory.getConnection(SingleConnectionFactory.java:340)
at .springframework.jms.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:245)
at .springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:211)
at .springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:517)
... 5 more Caused by: ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ219007: Cannot connect to server(s). Tried with all available servers.]
at .apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:729)
at .apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:910)
... 13 more