BAEL-4648: How to debug Websockets (#11469)

* BAEL-4648: How to debug Websockets

* Formatted the code

* Incorporated comments from Kevin
This commit is contained in:
Bhaskara
2021-11-29 05:02:23 +05:30
committed by GitHub
parent b806296685
commit d7f3f90731
7 changed files with 248 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
package com.baeldung.debugwebsockets;
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
import org.springframework.messaging.simp.stomp.StompSessionHandler;
import org.springframework.web.socket.client.WebSocketClient;
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import org.springframework.web.socket.messaging.WebSocketStompClient;
import java.util.Scanner;
public class StompWebSocketClient {
private static final String URL = "ws://localhost:8080/stock-ticks/websocket";
public static void main(String[] args) {
WebSocketClient client = new StandardWebSocketClient();
WebSocketStompClient stompClient = new WebSocketStompClient(client);
stompClient.setMessageConverter(new MappingJackson2MessageConverter());
StompSessionHandler sessionHandler = new StompClientSessionHandler();
stompClient.connect(URL, sessionHandler);
new Scanner(System.in).nextLine();
}
}