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

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

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

WebSocketStompClient.setTaskScheduler介绍

[英]Also automatically sets the #setDefaultHeartbeatproperty to "10000,10000" if it is currently set to "0,0".
[中]如果当前设置为“0,0”,也会自动将#setDefaultHeartbeatproperty设置为“1000010000”。

代码示例

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

@Test
public void heartbeatDefaultValueWithScheduler() throws Exception {
  WebSocketStompClient stompClient = new WebSocketStompClient(mock(WebSocketClient.class));
  stompClient.setTaskScheduler(mock(TaskScheduler.class));
  assertArrayEquals(new long[] {10000, 10000}, stompClient.getDefaultHeartbeat());
  StompHeaders connectHeaders = stompClient.processConnectHeaders(null);
  assertArrayEquals(new long[] {10000, 10000}, connectHeaders.getHeartbeat());
}

代码示例来源: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: 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.
  }
}

相关文章