Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. package sysmakers.hal;
  2.  
  3. import org.springframework.context.annotation.Bean;
  4. import org.springframework.context.annotation.Configuration;
  5. import org.springframework.messaging.simp.config.MessageBrokerRegistry;
  6. import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
  7. import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
  8. import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
  9. import org.springframework.web.socket.config.annotation.WebSocketTransportRegistration;
  10. import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
  11.  
  12. @Configuration
  13. @EnableWebSocketMessageBroker
  14. public class StompConfig implements WebSocketMessageBrokerConfigurer {
  15. private static final int MESSAGE_BUFFER_SIZE = 200 * 1024 * 1024;
  16. private static final long SECOND_IN_MILLIS = 1000L;
  17. private static final long HOUR_IN_MILLIS = SECOND_IN_MILLIS * 60 * 60;
  18.  
  19. @Override
  20. public void configureMessageBroker(MessageBrokerRegistry config) {
  21. config.enableSimpleBroker("/demo");
  22. config.enableSimpleBroker("/listen");
  23. }
  24.  
  25. @Override
  26. public void registerStompEndpoints(StompEndpointRegistry registry) {
  27. registry.addEndpoint("/stomp-registry").setAllowedOrigins("*");
  28. }
  29.  
  30. @Bean
  31. public ServletServerContainerFactoryBean createWebSocketContainer() {
  32. ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
  33. container.setMaxTextMessageBufferSize(MESSAGE_BUFFER_SIZE);
  34. container.setMaxBinaryMessageBufferSize(MESSAGE_BUFFER_SIZE);
  35. container.setMaxSessionIdleTimeout(HOUR_IN_MILLIS);
  36. container.setAsyncSendTimeout(SECOND_IN_MILLIS);
  37. return container;
  38. }
  39.  
  40. @Override
  41. public void configureWebSocketTransport(WebSocketTransportRegistration registration) {
  42. registration.setSendTimeLimit(60 * 1000)
  43. .setSendBufferSizeLimit(MESSAGE_BUFFER_SIZE)
  44. .setMessageSizeLimit(MESSAGE_BUFFER_SIZE);
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement