ActiveMQ 没有持久性

发布于 2024-09-27 23:23:24 字数 634 浏览 5 评论 0原文

我想在生成消息的服务器和接收消息的许多客户端之间建立基于发布者-订阅者的通信协议。经过一番研究后,我决定使用 ActiveMQ。我查看了一些教程和 ActiveMQ 站点,并按如下方式设置代理:

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

我只需要消息传递功能,不需要数据库持久性或类似的东西。但是,当我启动应用程序时,无论配置如何,都会创建一个 activemq-data 文件夹。这反过来会在我下次启动代理时导致异常。

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

这是一个错误还是我没有正确设置代理(使用 ActiveMQ 5.4.1)?如何禁用持久性,以便不创建额外的数据存储?另外,我更喜欢在 Java 应用程序中配置代理,而不是通过 xml 文件。

干杯, 最大限度

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

奈何桥上唱咆哮 2024-10-04 23:23:24

您还可以为消息生产者设置传递模式。

messageProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

JMS 允许的整数值为:

    int NON_PERSISTENT = 1;
    int PERSISTENT = 2;

You can also set the delivery mode for your message producer.

messageProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

Integer values allowed by JMS are:

    int NON_PERSISTENT = 1;
    int PERSISTENT = 2;
梓梦 2024-10-04 23:23:24

这不是正常行为,而是 KahaDB(Activemq 中的默认持久性存储)中的一个错误。

您可以在 ActiveMQ 的错误 2935

您可以通过选择不同的持久性引擎来解决这个问题,尽管我奇怪地遇到过这个问题几次,然后它就消失了

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

三生一梦 2024-10-04 23:23:24

就我而言,从以下目录中删除所有 kahadb 数据文件会有所帮助:

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

然后:

sudo service activemq restart

一切都恢复正常

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

深海少女心 2024-10-04 23:23:24

如果使用maven pom,则切换到
`

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

`
另外不要忘记清除KahaDB和Scheduler中的内容。
如果不需要的话,它还有助于关闭调度程序。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文