[英]How to store netty Channel object in Redis database or any other solution?
As i am using netty to make chat application.As i have cluster of netty servers. 由于我正在使用netty进行聊天应用程序。由于我拥有netty服务器集群。
As i am storing channel id of all clients in Redis to have reference of all channels which are connected to netty servers. 因为我在Redis中存储所有客户端的通道ID,以获取连接到Netty服务器的所有通道的引用。
I want to store all Channel objects to Redis so that from any node or instance i can get all clients Channel objects because node on which if i want to get other clients Channel which are created on some other node, How to get those client Channel objects which reside on other node or instance? 我想将所有Channel对象存储到Redis,以便可以从任何节点或实例获取所有客户端Channel对象,因为如果要获取在其他节点上创建的其他客户端Channel的节点,如何获取这些客户端Channel对象哪个驻留在其他节点或实例上?
So its better to store client Channel object to redis so from any node i can get any client Channel object. 因此最好将客户端Channel对象存储到Redis,这样我就可以从任何节点获取任何Client Channel对象。 but Channel implementing class is not Serializable in netty.
但是Channel实现类不能在Netty中序列化。
Thanks. 谢谢。
Channel in Netty contains implicitely all network aspects (socket, nio support, tcp or udp or ...), therefore you can not serialize it (a network connection cannot be serialized). Netty中的Channel隐式包含所有网络方面(套接字,Nio支持,tcp或udp或...),因此您无法对其进行序列化(无法对网络连接进行序列化)。
But you can serialize the remote address. 但是您可以序列化远程地址。 Note however that the "id" is not configurable, meaning you cannot force its value for one channel.
但是请注意,“ id”是不可配置的,这意味着您不能为一个通道强制使用其值。 So you might use something like:
因此,您可能会使用类似:
In Redis or so: (your id being the key) 在Redis左右:(您的ID是密钥)
In your JVM (node): (map where your id is the key) 在您的JVM(节点)中:(映射您的id是键)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.