Netty High Availability Cluster

蹲街弑〆低调 提交于 2019-12-22 18:01:38

问题


Wondering if Netty has any examples of how I can create a high availability application whereby the netty client will use a backup server in case of live server failure.


回答1:


If you want to make the client and server highly available and to manage the connections state by your code with ease, Have a look on Akka Remote Actor API which is using Netty for underlying communication .




回答2:


There is no example of this. But I think its quite straight-forward. You need to have a pool of different "channels" that are connected to remote hosts. The do something like this:

channel.write(msg).addListener() {
    public void operationComplete(ChannelFuture future) {
        if (!future.isSuccess) {
            ... // get next channel from the pool and try the write there etc..
        }
    }
}

Hope it helps..



来源:https://stackoverflow.com/questions/8725228/netty-high-availability-cluster

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!