优先级队列和优先级队列坚持

发布于 2024-12-22 03:26:43 字数 347 浏览 4 评论 0原文

我有一个 Java 系统,它通过网络以专有的二进制格式接收消息,它需要对其进行解码、处理和执行某些操作。这些消息具有隐含的优先级,具体取决于其有效负载。我想在系统中使用优先级队列的语义,并使用单独的消费者线程读取队列。问题是,一旦系统通过网络接受了消息,它就必须保证最终能够处理它,即使系统在接收和处理之间发生了故障。因此,我想坚持不懈地支持我的优先级队列。我正在寻找轻量级的方法来在 Web 容器进程内的 Java 中实现此目的,而不是使用完全成熟的 ESB 或类似的方法。

一些附加信息:我们位于 Amazon 云中,不幸的是,JMS 在我们的环境中不是一个选项。我们可以使用 SQS,但这不支持优先级概念,并且需要轮询,这并不是很理想。

谢谢

I have a Java system that receives messages over the network in a proprietary binary format which it needs to decode, process and do something with. The messages have an implied priority depending on their payload. I'd like to use the semantics of a priority-queue in the system with separate consumer threads reading the queue. The problem, is that once the system has accepted a message over the network, it must guarantee to handle it eventually, even if the system went down between receipt and processing. As such I'd like to back my priority-queue with persistence. I'm looking for light-weight ways to achieve this in Java inside a web container process as against using a fully blown ESB or similar.

Some additional info: we are in the Amazon cloud and JMS is not an option in our environment unfortunately. We could use SQS, but this doesn't support a priority concept and requires polling which is not really ideal.

Thanks

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

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

发布评论

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

评论(1

雄赳赳气昂昂 2024-12-29 03:26:43

SQS 使用长轮询,因此它增加的开销非常低,而且几乎没有延迟。对于优先级,您可以使用多个队列。每个优先级一个。

SQS uses long polling, so it adds very low overhead and practically no latency. For priorities you can use multiple queues. One for each priority.

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