使用zeromq,发送者发送10条消息后,发送者崩溃。
场景1: 接收方正在一条一条地处理消息,花费了一些明显的时间成本,在这种情况下它还会收到 10 条消息吗?
场景 2: 另一种情况是,当接收器崩溃时,接收器恢复后,能否继续接收停电期间丢失的内容?
场景 3: 如果接收者因队列中的待处理消息而崩溃,另一个接收者开始监听队列,它可以获取队列中剩余的内容吗?
最佳答案
scenario 1: the receiver is processing the messages one by one with some noticeable time cost, will it still get the 10 messages in this scenario?
如果发送方收到了所有消息,那么它们将位于接收方队列中。假设您已为接收器设置了足够高的高水位线选项,那么它应该处理所有这些选项。
scenario 2: another scenario is when receiver crashes, after receiver is recovered, can it continue to receive what it missed during its blackout?
假设发送方也没有崩溃:发送方仍会将消息排队在该接收方的传出队列中。只要排队的消息数量不超过发送方设置的高水位线选项,接收方在重新连接时就会收到所有待处理的消息。
scenario 3: if the receiver crashed with pending messages in the queue, another receiver starts to listen to the queue, can it get what's left in the queue?
ZeroMQ 为每个对等方保留一个队列。这样队列就会丢失。这是假设您使用简单的点对点方法。如果您使用 PUBLISHER->SUBSCRIBER,则多个接收者可以共享同一个队列。
关于zeromq - Zeromq 是否保证发送方/接收方崩溃后的交付?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21215687/