本文介绍了通过Netty的Channel.write()发送的消息在开始发送到网络时是否保留其顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行某种加密,具体取决于通过Netty通道发送的消息的顺序.我所期望的是,如果我在消息B之前将消息A写入通道,则应按照将它们写入通道的相同顺序将它们发送到远程套接字.那我需要Netty已经支持的情况吗?

I am doing some sort of encryption which depends of the order of messages sent via a Netty channel. What I am expecting is that if I write message A before message B to a channel then they should be sent to the remote socket in the same order I have written them to the channel. So is the case I need already supported by Netty?

另一方面,Netty's Channel接受并发写入调用,我不确定我的要求是否已经满足.由于数据结构的崩溃状态,我今天不得不在一个全状态(每通道一个)编码器上进行同步.但是,我仍然不确定过滤器内同步是否可以满足我的需求.

On the other hand Netty's Channel accepts concurrent write calls and I am in doubt my requirement can already met. I had to synchronize on a statefull (a per channel one) encoder today due to currupt state of a data structure. However I am still not sure whether the in-filter synchronization will help my need.

推荐答案

是的,消息将按照与调用Channel.write(..)相同的顺序进行传输.这里您无需担心.

Yes, the messages will get transfered in the same order as you call Channel.write(..). There is nothing you need to worry about here.

这篇关于通过Netty的Channel.write()发送的消息在开始发送到网络时是否保留其顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 16:01