I want to transffer high frequency realtime data from one location to othere using WebSocket in Spring. I have done this task, If I transfer data from server to browser.But My need is different, I have to send data from server to client(but client will be java class rather than browser).I have done code Server side as bellow:-
String dcEndPoint = DiUtils.getPropertyValue(LGRConstants.DATACENTER_WEBSOCKET_ENDPOINT);
List<Transport> transports = new ArrayList<Transport>(2);
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
transports.add(new RestTemplateXhrTransport());
SockJsClient sockJsClient = new SockJsClient(transports);
//sockJsClient.doHandshake(new DCWebSocketHandler(), dcEndPoint);
//sockJsClient.start();
AbstractWebSocketHandler webSocketHandler = new TextWebSocketHandler() {
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
loggingServiceInterface.logInfo("connected");
}
@Override
public void handleMessage(WebSocketSession session,
WebSocketMessage<?> message) throws Exception {
super.handleMessage(session, message);
session.sendMessage(null);
}
};
sockJsClient.doHandshake(webSocketHandler, new WebSocketHttpHeaders(),
new URI(dcEndPoint)).get(3000, TimeUnit.SECONDS);
But problem is how to define java client for recieving data.Please anyone guide me.Is any other option there for doing same thing.Am I going wrong please guide me.
Aucun commentaire:
Enregistrer un commentaire