-
Notifications
You must be signed in to change notification settings - Fork 185
Open
Description
场景复现:
1、服务端,每秒钟推送一次
public static void main(String[] args)throws Exception{
HproseTcpServer server=new HproseTcpServer("tcp://127.0.0.1:4321");
server.publish("time",12000,3000);
server.start();
Timer timer=new Timer();
timer.schedule(new TimerTask() {
@OverRide
public void run() {
System.out.println(LocalDateTime.now()+" "+ JSON.toJSONString(server.idlist("time") )+" "+ LocalTime.now().getSecond());
server.unicast("time","test",LocalTime.now().getSecond());
}
},0,1000);
}
2、客户端订阅接收
public static void main(String[] args) throws Exception{
//订阅服务
HproseClient client=HproseClient.create("tcp://127.0.0.1:4321");
Thread thread=new Thread(new Runnable() {
@Override
public void run() {
client.subscribe("time","test",(String msg)->{
System.out.println(LocalDateTime.now()+" "+msg );
},String.class);
}
});
thread.start();
}
Metadata
Metadata
Assignees
Labels
No labels

