本文介绍了可以在ZeroMQ中回复吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在ZeroMQ中实施。

我正在考虑用C或Java编写解决方案,但问题的核心似乎是语言中立。



在我的问题中,我有三种消息类型,我们称之为请求回复发布请求 / 回复消息非常适合REQ / REP模式,但发布消息是单向信号,不需要回复。我可以添加一个额外的PUB / SUB对,但是,根据我的理解,我将无法保证系统中的FIFO传送顺序,因为我最终会有两个并发的TCP连接(这个假设是对的吗?)。 / p>

我可以使用基本的非约束fullduplex通道。另一个建议使用DEALER / ROUTER对,但对于这样一个简单的问题来说,这似乎有些过分。在文档中,在中描述了DEALER / ROUTER章,我的问题似乎不需要极端的解决方案。



我的问题如何解决?

解决方案



短版本:可以。



正确设置 .setsockopt( zmq.REQ_RELAXED,1)






更长的版本:



如果确实分布式系统应该获得稳健性,那么定义问题还有更多问题需要解决。 REQ / REP 不需要陷入主要的无法解决的相互死锁,因为分布式FSA是 .REQ_RELAXED的快捷方式设置,但ZeroMQ不提供邮件传递的保证。这是一种尽力交付,因此如果需要有保证的消息传递,您需要实施更高级别的协议握手。
设置 .setsockopt(zmq.REQ_CORRELATE,1) 可能会有所帮助。


I'm implementing a Lamport's distributed MUTEX algorithm in ZeroMQ.

I'm considering coding the solution in C or Java, but the core of the problem seems to be language-neutral.

In my problem, I have three message types, let's call them Request, Reply and Release. The Request/Reply messages fit well into REQ/REP pattern, but the Release message is one-way signal and does not need a reply. I could add an additional PUB/SUB pair, but then, in my understanding, I will not have the guarantee of FIFO delivery order in the system, because I would end up having two concurrent TCP connections (is this assumption right?).

I could make use of a basic non-constrained fullduplex channel. Another answer suggests using DEALER/ROUTER pair, but it seems like an overkill for such a simple problem. In docs, DEALER/ROUTER is described in Advanced Request-Reply Patterns chapter, and my problem doesn't seem to need an extreme solution.

How can my problem be solved?

解决方案

Short version: Can.

just set properly .setsockopt( zmq.REQ_RELAXED, 1 )


Longer version:

There will be more issues yet to be solved for defined problem, if indeed distributed-system ought gain robustness. REQ/REP need not fall into a principally unsalvageable mutual-deadlock, as a distributed-FSA was shortcut with .REQ_RELAXED settings, yet ZeroMQ does not provide warranty for a message delivery. It is a best-effort delivery, so you need to implement a higher-level protocol handshaking, if in a need for a guaranteed message delivery.Setting .setsockopt( zmq.REQ_CORRELATE, 1 ) may help in this.

这篇关于可以在ZeroMQ中回复吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-04 08:24