我了解它的方式,你需要发现你的tomcat服务器的IP,并使用你的客户端连接它。
我假设,服务器和客户端都在您的控制之下。 一个简单的方法可以使用jGroups集群。
你可以让你的tomcat发现
客户端可以使用您所提供.Refer是JGroups的使用
我模拟它做以下服务器类的
JChannel API集群的名称发现它
public class TomcatServer {
JChannel channel;
private void start() throws Exception {
channel = new JChannel(); // use the default config, udp.xml
channel.connect("TomcatCluster");
}
public static void main(String[] args) throws Exception {
new TomcatServer().start();
}
}
模拟客户端类
public class MobileApp extends ReceiverAdapter {
JChannel channel;
private void start() throws Exception {
channel = new JChannel(); // use the default config, udp.xml
channel.setReceiver(this);
channel.connect("TomcatCluster");
channel.close();
}
public static void main(String args[]) throws Exception {
new MobileApp().start();
}
客户端将提供以下信息
GMS:地址= MACHINENAME-47879,簇= TomcatCluster,物理地址= XXXXX:0:XXX:XXXX:XXXX:XXXX:XXX:XXXX:XXXX
**视图:[MACHINENAME-31239 | 1] [MACHINENAME-31239,MACHINENAME-47879]
凡MACHINENAME-47879是在客户机和端口& MACHINENAME-31239是Tomcat服务器名称和端口