org.springframework.web.socket.messaging.WebSocketStompClient.setMessageConverter()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.springframework.web.socket.messaging.WebSocketStompClient.setMessageConverter()方法的一些代码示例,展示了WebSocketStompClient.setMessageConverter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebSocketStompClient.setMessageConverter()方法的具体详情如下:
包路径:org.springframework.web.socket.messaging.WebSocketStompClient
类名称:WebSocketStompClient
方法名:setMessageConverter

WebSocketStompClient.setMessageConverter介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Before
public void setUp() throws Exception {
  logger.debug("Setting up before '" + this.testName.getMethodName() + "'");
  this.wac = new AnnotationConfigWebApplicationContext();
  this.wac.register(TestConfig.class);
  this.wac.refresh();
  this.server = new TomcatWebSocketTestServer();
  this.server.setup();
  this.server.deployConfig(this.wac);
  this.server.start();
  WebSocketClient webSocketClient = new StandardWebSocketClient();
  this.stompClient = new WebSocketStompClient(webSocketClient);
  this.stompClient.setMessageConverter(new StringMessageConverter());
}

代码示例来源:origin: spring-projects/spring-integration

@Bean
public WebSocketStompClient stompClient(TaskScheduler taskScheduler) {
  WebSocketStompClient webSocketStompClient = new WebSocketStompClient(webSocketClient());
  webSocketStompClient.setMessageConverter(new MappingJackson2MessageConverter());
  webSocketStompClient.setTaskScheduler(taskScheduler);
  return webSocketStompClient;
}

代码示例来源:origin: spring-projects/spring-integration

@Bean
public WebSocketStompClient stompClient(TaskScheduler taskScheduler) {
  WebSocketStompClient webSocketStompClient = new WebSocketStompClient(webSocketClient());
  webSocketStompClient.setTaskScheduler(taskScheduler);
  webSocketStompClient.setReceiptTimeLimit(5000);
  webSocketStompClient.setMessageConverter(new StringMessageConverter());
  return webSocketStompClient;
}

代码示例来源:origin: mthizo247/spring-cloud-netflix-zuul-websocket

@Bean
@ConditionalOnMissingBean(WebSocketStompClient.class)
public WebSocketStompClient stompClient(WebSocketClient webSocketClient, MessageConverter messageConverter,
                    @Qualifier("proxyStompClientTaskScheduler") TaskScheduler taskScheduler) {
  int bufferSizeLimit = 1024 * 1024 * 8;
  WebSocketStompClient client = new WebSocketStompClient(webSocketClient);
  client.setInboundMessageSizeLimit(bufferSizeLimit);
  client.setMessageConverter(messageConverter);
  client.setTaskScheduler(taskScheduler);
  client.setDefaultHeartbeat(new long[]{0, 0});
  return client;
}

代码示例来源:origin: stackoverflow.com

WebSocketClient transport = new StandardWebSocketClient();
WebSocketStompClient stompClient = new WebSocketStompClient(transport);
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
stompClient.setMessageConverter(converter);
StompSessionHandler handler = new WSClient(); //custom implementation
String url = "ws://{URL}/ws/websocket";
stompClient.connect(url, handler);

代码示例来源:origin: CaledoniaProject/CVE-2018-1270

public static void main(String... argv) {
    WebSocketClient webSocketClient = new StandardWebSocketClient();
    WebSocketStompClient stompClient = new WebSocketStompClient(webSocketClient);
    stompClient.setMessageConverter(new MappingJackson2MessageConverter());
    stompClient.setTaskScheduler(new ConcurrentTaskScheduler());

    String url = "ws://127.0.0.1:8080/hello";
    StompSessionHandler sessionHandler = new MySessionHandler();
    stompClient.connect(url, sessionHandler);

    new Scanner(System.in).nextLine(); //Don't close immediately.
  }
}

相关文章