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:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user