14 Mart 2018 Çarşamba

SpringStomp WebSocketStompClient Sınıfı - Stomp Client İçin Kullanılır

constructor - SockJsClient
Şöyle yaparız.
WebSocketClient simpleWebSocketClient = new StandardWebSocketClient();
List<Transport> transports = new ArrayList<>(1);
transports.add(new WebSocketTransport(simpleWebSocketClient));

SockJsClient sockJsClient = new SockJsClient(transports);
WebSocketStompClient stompClient = new WebSocketStompClient(sockJsClient);
connect metodu
ListenableFuture<StompSession> nesnesi döner. 
Örnek
Şöyle yaparız.
String url = "ws://localhost:9080/Vault713MQServer/websocket";

StompSessionHandler sessionHandler = ...;
StompSession session = stompClient.connect(url, sessionHandler).get();
Örnek
Şöyle yaparız
WebSocketClient transport = new StandardWebSocketClient();
WebSocketStompClient stompClient = new WebSocketStompClient(transport);
WebSocketHttpHeaders webSocketHttpHeaders = new WebSocketHttpHeaders();
webSocketHttpHeaders.add("Authorization","Bearer XXXXXX");
stompClient.setMessageConverter(new StringMessageConverter());
stompClient.connect("ws://localhost:8080/test", webSocketHttpHeaders,
new CustomStompSessionHandler())
setMessageConverter metodu
Şöyle yaparız.
WebSocketClient simpleWebSocketClient = new StandardWebSocketClient();
List<Transport> transports = new ArrayList<>(1);
transports.add(new WebSocketTransport(simpleWebSocketClient));
SockJsClient sockJsClient = new SockJsClient(transports);
stompClient = new WebSocketStompClient(sockJsClient);
stompClient.setMessageConverter(new MappingJackson2MessageConverter());

Hiç yorum yok:

Yorum Gönder