Unfortunately it looks like it's not easy (for me) to replicate in a simple application.
It looks like the issue is related to a shutdown hook somehow resurrecting the broker after the broker was stopped. Unfortunately the logging lines are a bit long so I hope it's somewhat readable. The shutdown logging shows that ActiveMQ is shutting down but then just after the shutdown hook, a new instance of the BrokerService is created with the default values. For example it reports a warning about max memory 1024mb. In the spring config however the max memory is set to 20MB. INFO Apache ActiveMQ 5.16.0 (localhost, ID:martijn-laptop-45763- 1607698489325-0:1) is shutting down (org.apache.activemq.broker.BrokerService) [ActiveMQ ShutdownHook] INFO Connector vm://localhost stopped (org.apache.activemq.broker.TransportConnector) [ActiveMQ ShutdownHook] INFO PListStore:[/home/martijn/git/ciphermail-core/var/jms- data/localhost/tmp_storage] stopped (org.apache.activemq.store.kahadb.plist.PListStoreImpl) [ActiveMQ ShutdownHook] INFO Stopping async queue tasks (org.apache.activemq.store.kahadb.KahaDBStore) [ActiveMQ ShutdownHook] INFO Stopping async topic tasks (org.apache.activemq.store.kahadb.KahaDBStore) [ActiveMQ ShutdownHook] INFO Stopped KahaDB (org.apache.activemq.store.kahadb.KahaDBStore) [ActiveMQ ShutdownHook] WARN Memory Usage for the Broker (1024mb) is more than the maximum available for the JVM: 455 mb - resetting to 70% of maximum available: 318 mb (org.apache.activemq.broker.BrokerService) [org.springframework.jms.listener.DefaultMessageListenerContainer#0-1] INFO Using Persistence Adapter: KahaDBPersistenceAdapter[/home/martijn/git/ciphermail-core/activemq- data/localhost/KahaDB] (org.apache.activemq.broker.BrokerService) [org.springframework.jms.listener.DefaultMessageListenerContainer#0-1] INFO Apache ActiveMQ 5.16.0 (localhost, ID:martijn-laptop-45763- 1607698489325-0:1) uptime 7.446 seconds (org.apache.activemq.broker.BrokerService) [ActiveMQ ShutdownHook] INFO Apache ActiveMQ 5.16.0 (localhost, ID:martijn-laptop-45763- 1607698489325-0:1) is shutdown (org.apache.activemq.broker.BrokerService) [ActiveMQ ShutdownHook] A simple test application does not show this issue. If I disable (i.e., comment out) the following DefaultMessageListenerContainer, then the shutdown works normally. <bean class="org.springframework.jms.listener.DefaultMessageListenerContainer " > <property name="connectionFactory" ref="connectionFactory"/> <property name="destination" ref="certificateCreatedTopic"/> <property name="sessionTransacted" value="true" /> <property name="pubSubDomain" value="true"/> <property name="subscriptionDurable" value="true" /> <property name="clientId" value="ciphermail.gateway" /> <property name="durableSubscriptionName" value="certificate- created-listener" /> </bean> For some reason adding DefaultMessageListenerContainer instance somehow results in restarting and instance of BrokerService which is then shutdown. Any idea? Kind regards, Martijn Brinkers On Fri, 2020-12-11 at 06:09 -0700, Tim Bain wrote: > This sounds like a bug. Please submit a bug in JIRA, ideally > attaching a > minimal reproducer. > > Thanks, > Tim > > On Fri, Dec 11, 2020, 5:58 AM Martijn Brinkers (list) < > martijn.l...@gmail.com> wrote: > > > I have embedded ActiveMQ inside a spring application. > > > > The broker is configured in XML and I explicitly set the > > dataDirectory: > > > > <amq:broker useJmx="false" persistent="true" > > dataDirectory="var/jms"> > > <amq:transportConnectors> > > <amq:transportConnector uri="vm://localhost" /> > > </amq:transportConnectors> > > </amq:broker> > > > > When I startup my application, the var/jms directory is created and > > JMS > > messages are stored when required. If however I shutdown my > > application, an addtional directory "activemq- > > data/localhost/KahaDB" is > > created. This only happens if "useShutdownHook" is true (which is > > the > > default). > > > > It looks like the shutdownhook tries to create the "data directory" > > but ignores the configured value and therefore uses the default > > data > > directory name. > > > > Is this a bug? Or did I make a configuration error? > > > > Kind regards, > > > > Martijn Brinkers > > > >