Spring Boot same broker messages repeated to console Spring Boot same broker messages repeated to console spring spring

Spring Boot same broker messages repeated to console


I cannot explain in-depth why this happens, but it has something to do with the way the ConnectionFactory is auto-configured.

One way to get rid of this constant restarting of the embedded broker is to enable pooling in your application.properties:

spring.activemq.pooled=true

In order to use this you also have to add the following dependency to your pom.xml:

<dependency>    <groupId>org.apache.activemq</groupId>    <artifactId>activemq-pool</artifactId></dependency> 

I've dug through some documentation and eventually found this

At the bottom of the page it reads:

Using ActiveMQConnectionFactory
...
The broker will be created upon creation of the first connection.
...

Again, this doesn't fully explain what's going on, but I stopped digging once I found that enabling pooling stopped this behaviour from happening.


Met the same problem but the accepted answer did not help. Found the thread with explanation

ActiveMQ will only keep an in-memory queue alive if there is something holding onto it.

If the Queue has been setup in spring to not cache the queue then ActiveMQ will keep starting/stopping the connector. A full appserver would effectively cache queue stuff in a pool, thus keeping it alive.

Stick in the bean def for the Spring JMS container (org.springframework.jms.listener.DefaultMessageLi stenerContainer) to fix the problem.

@Beanpublic JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory,                                                DefaultJmsListenerContainerFactoryConfigurer configurer) {    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();    factory.setCacheLevelName("CACHE_CONNECTION"); //<-- the line fixed the problem    configurer.configure(factory, connectionFactory);    return factory;}


We have spring boot 1.5 services which consume and publish via JMSTemplate and do not have this problem and then we have one which only publishes (so no JmsListener) and fills logs with these messages - plus the related WARN Temporary Store limit is 51200 mb ... resetting to maximum available disk space - writing them on every GET to /healthcheck. You'll want to consider the implications but this behaviour and hence all the related logging can be disabled with the property setting:

management.health.jms.enabled=false

You'll see the jms block disappear from your /healthcheck output as a result - so check whether it is actually reflecting anything required by your service. We had no success with other answers on this thread nor with those we tried from Startup error of embedded ActiveMQ: Temporary Store limit is 51200 mb.