Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sysmakers.hal;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.messaging.simp.config.MessageBrokerRegistry;
- import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
- import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
- import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
- import org.springframework.web.socket.config.annotation.WebSocketTransportRegistration;
- import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
- @Configuration
- @EnableWebSocketMessageBroker
- public class StompConfig implements WebSocketMessageBrokerConfigurer {
- private static final int MESSAGE_BUFFER_SIZE = 200 * 1024 * 1024;
- private static final long SECOND_IN_MILLIS = 1000L;
- private static final long HOUR_IN_MILLIS = SECOND_IN_MILLIS * 60 * 60;
- @Override
- public void configureMessageBroker(MessageBrokerRegistry config) {
- config.enableSimpleBroker("/demo");
- config.enableSimpleBroker("/listen");
- }
- @Override
- public void registerStompEndpoints(StompEndpointRegistry registry) {
- registry.addEndpoint("/stomp-registry").setAllowedOrigins("*");
- }
- @Bean
- public ServletServerContainerFactoryBean createWebSocketContainer() {
- ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
- container.setMaxTextMessageBufferSize(MESSAGE_BUFFER_SIZE);
- container.setMaxBinaryMessageBufferSize(MESSAGE_BUFFER_SIZE);
- container.setMaxSessionIdleTimeout(HOUR_IN_MILLIS);
- container.setAsyncSendTimeout(SECOND_IN_MILLIS);
- return container;
- }
- @Override
- public void configureWebSocketTransport(WebSocketTransportRegistration registration) {
- registration.setSendTimeLimit(60 * 1000)
- .setSendBufferSizeLimit(MESSAGE_BUFFER_SIZE)
- .setMessageSizeLimit(MESSAGE_BUFFER_SIZE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement