diff options
author | Vitaly Takmazov | 2017-10-16 00:51:54 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-10-16 00:51:54 +0300 |
commit | 4687e8130f722b05239fa9570f73c60aa4f16bc7 (patch) | |
tree | 389144a0c17d57da32d460b8c20970b0722031e1 | |
parent | 9a4add44ecbd32dea6ac3d30fd81ae1ac82e3dbc (diff) |
ws: fix scheduler config
-rw-r--r-- | juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java index a4317601..8e2659a3 100644 --- a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java +++ b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java @@ -22,12 +22,17 @@ import com.juick.server.protocol.JuickProtocol; import com.juick.ws.WebsocketComponent; import org.springframework.context.annotation.*; import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.SchedulingConfigurer; +import org.springframework.scheduling.config.ScheduledTaskRegistrar; import org.springframework.web.socket.config.annotation.EnableWebSocket; import org.springframework.web.socket.config.annotation.ServletWebSocketHandlerRegistry; import org.springframework.web.socket.config.annotation.WebSocketConfigurer; import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; + /** * Created by aalexeev on 11/24/16. */ @@ -36,7 +41,7 @@ import org.springframework.web.socket.server.standard.ServletServerContainerFact @EnableScheduling @EnableWebSocket @PropertySource("classpath:juick.conf") -class WebsocketConfiguration extends BaseWebConfiguration implements WebSocketConfigurer { +class WebsocketConfiguration extends BaseWebConfiguration implements WebSocketConfigurer, SchedulingConfigurer { @Bean public WebsocketComponent wsHandler() { @@ -61,4 +66,13 @@ class WebsocketConfiguration extends BaseWebConfiguration implements WebSocketCo container.setMaxBinaryMessageBufferSize(8192); return container; } + @Override + public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { + taskRegistrar.setScheduler(taskExecutor()); + } + + @Bean(destroyMethod="shutdown") + public Executor taskExecutor() { + return Executors.newScheduledThreadPool(100); + } } |