Disposal of activemq embedded data during testing

I actively use ActiveMQin my project. Although a standalone ActiveMQinstance is used for production , my tests require a built-in instance ActiveMQ. After executing a specific testing method, ActiveMQstores raw messages in queues. I would like to destroy the instance ActiveMQafter each test. I tried using JMXto connect to a local instance ActiveMQand destroying the queues, but this is a tough decision. Can someone suggest me something easier?

+4
source share
3 answers

just turn off broker durability when you determine the broker url for your unit tests

vm://localhost?broker.persistent=false
+3
source

ActiveMQ has the ability to delete all messages at startup, if you use the ActiveMQ broker XML configuration method, you can set it to <activemq>,

<activemq:broker .... deleteAllMessagesOnStartup="true">

   ...
</activemq:broker>

Another approach might be to use unique data directories for the unit test, which we do when testing the camel-jms component with the built-in ActiveMQ broker. We have a helper class that sets up ActiveMQ for us, depending on whether we need constant queues or not.

https://git-wip-us.apache.org/repos/asf?p=camel.git;a=blob;f=components/camel-jms/src/test/java/org/apache/camel/component/ jms / CamelJmsTestHelper.java; h = 8c81f3e2bed738a75841988fd1239f54a100cd89; hb = HEAD

+1

, . .

https://activemq.apache.org/how-do-i-purge-a-queue.html

" - , / , / . - JMX purge() QueueViewMBean. removeQueue (String) removeTopic (String) BrokerViewMBean. "

-1

All Articles