ActiveMQ without persistence

2019-05-27 04:06发布

I'd like to set up a publisher-subscriber based communication protocol between a server producing messages and many clients receiving them. After a bit of research, I decided to go with ActiveMQ. I looked at a few tutorials and the ActiveMQ site and set up the broker as follows:

BrokerService broker = new BrokerService();
broker.setPersistent(false);
broker.addConnector("tcp://localhost:61616");
broker.start();

I only need the message passing functionality, no database persistence or anything alike. However, when I start the application, a activemq-data folder is created regardless of the the configuration. This in turn causes an exception the next time I start the broker.

SEVERE: Failed to start ActiveMQ JMS Message Broker. Reason: java.io.EOFException: Chunk stream does not exist at page: 0

Is this a bug or am I not setting up the broker correctly (using ActiveMQ 5.4.1)? How can I disable persistence, so the additional data storage is not created? Also, I prefer to configure the broker from within the Java application and not through an xml file.

Cheers, Max

3条回答
迷人小祖宗
2楼-- · 2019-05-27 04:49

This is not normal behaviour but a bug in KahaDB (the default persistence store in Activemq)

You can see info on Bug 2935 of ActiveMQ.

You could solve this by choosing a different persistence engine, although i strangly had this problem a couple of times and then it dissapeared

查看更多
戒情不戒烟
3楼-- · 2019-05-27 04:58

In my case remove all of the kahadb data files from the following directory helps:

$ ls /var/lib/activemq/main/data$ cd kahadb
db-1.log  db.data  db.redo  lock

then:

sudo service activemq restart

and everything back to work

查看更多
欢心
4楼-- · 2019-05-27 05:06

if using maven pom, then switch to `

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-all</artifactId>
    <version>5.8.0</version>
</dependency>

` also don't forget to clear out the contents in KahaDB and Scheduler. it also helps to turn the scheduler off, if not needed.

查看更多
登录 后发表回答