优先级队列和优先级队列坚持
我有一个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.