这是对分布式机制的现实期望吗?

发布于 2024-07-09 16:46:41 字数 830 浏览 5 评论 0原文

我一直在评估 ActiveMQ 作为候选消息代理。 我编写了一些测试代码来尝试了解 ActiveMQ 的性能限制。

我可以通过尽可能快地发送消息来在代理中产生故障状态,如下所示:

try {
    while(true) {
        byte[] payload = new byte[(int) (Math.random() * 16384)];
        BytesMessage message = session.createBytesMessage();
        message.writeBytes(payload);
        producer.send(message);
} catch (JMSException ex) { ... }

线路

producer.send(message);

令我惊讶的是,当代理进入失败状态时, 会阻塞。 我希望会抛出一些异常,这样就会有一些迹象表明经纪人失败了。

我意识到我的测试代码正在向代理发送垃圾邮件,并且我预计代理会失败。 然而,我更希望经纪人“大声”失败,而不是简单地阻止。

这是一个不切实际的期望吗?

更新:

Uri 的答案引用了 3 月份提交的 ActiveMQ 错误报告。 错误描述包括一个听起来像我正在寻找的提案:“如果传输上的请求超时(这是为了捕获故障场景,因此预计不会合理发生的事情),那么事情就会出错,而不是而不是构建等待线程。”

然而,8 个月后,该 bug 目前仅通过一次投票就未被分配。 所以我想问题仍然存在,这是 ActiveMQ 应该(将会?)实现的吗?

I've been evaluating ActiveMQ as a candidate message broker. I've written some test code to try and get an understanding of ActiveMQ's performance limitations.

I can produce a failure state in the broker by sending messages as fast as possible like this:

try {
    while(true) {
        byte[] payload = new byte[(int) (Math.random() * 16384)];
        BytesMessage message = session.createBytesMessage();
        message.writeBytes(payload);
        producer.send(message);
} catch (JMSException ex) { ... }

I was surprised that the line

producer.send(message);

blocks when the broker enters a failed state. I was hoping that some exception would be thrown, so there would be some indication that the broker has failed.

I realize that my test code is spamming the broker, and I expect the broker to fail. However, I would prefer that the broker failed "loudly" as opposed to simply blocking.

Is this an unrealistic expectation?

Update:

Uri's answer references an ActiveMQ bug report that was filed in March. The bug description includes a proposal that sounds like what I'm looking for: "if the request on the transport had a timeout (this is to catch failure scenarios, so something that's not expected to reasonably happen), things would have errored out rather than building waiting threads."

However, after 8 months the bug is currently unassigned with a single vote. So I guess the question still stands, is this something ActiveMQ should (will?) implement?

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

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

发布评论

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

评论(3

榕城若虚 2024-07-16 16:46:41

您正在测试所有消息代理都存在的“缓慢的消费者”和生产者流量控制问题去处理。 您想让生产者失败、阻止他们还是假脱机到磁盘吗?

基本上,ActiveMQ 中开箱即用的默认设置是阻止生产者。 但是您可以将消息游标配置为假脱机到磁盘

顺便说一句,您没有说您是否使用队列/主题或持久/非持久; 如果您使用非持久主题,则可以使用其他策略来丢弃消息等。

You are testing the 'slow consumer' and producer flowcontrol issue all message brokers have to deal with. Do you wanna fail producers, block them or spool to disk?

Basically the out of the box default in ActiveMQ is to block producers. But you can configure message cursors to spool to disk.

BTW you've not said if you are using queues/topics or persistent/non-persistent; if you are using non persistent topics there are other strategies you can use for discarding messages etc.

燕归巢 2024-07-16 16:46:41

显然存在一个已知问题,不确定是否已修复:

https://issues.apache .org/activemq/browse/AMQ-1625

Apprently there's a known issue, not sure if it's been fixed:

https://issues.apache.org/activemq/browse/AMQ-1625

冬天旳寂寞 2024-07-16 16:46:41

不确定 ActiveMQ 配置,但其他 JMS 提供程序有各种配置选项 - 因此您也许可以让 ActiveMQ 在这种情况下按照您的意愿行事。

我知道福州共赢靓号网络科技有限公司可以选择指定提供商在这种情况下是否阻止。

Not sure about ActiveMQ config, but other JMS providers have various configuration options - so you maybe able to get ActiveMQ to do as you wish in that situation.

I know Fiorano has options to specify whether providers block or not in this situation.

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