summaryrefslogtreecommitdiff
path: root/sw-server/src/main
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-06-02 23:32:42 +0200
committerJoffrey Bion <joffrey.bion@booking.com>2020-06-02 23:32:42 +0200
commit7499004f643fadc73f385328dbfa75af7dcb3795 (patch)
tree7e6fed456b1c4409f2682335577164fcc7b40463 /sw-server/src/main
parentUpdate README with latest added features (diff)
downloadseven-wonders-7499004f643fadc73f385328dbfa75af7dcb3795.tar.gz
seven-wonders-7499004f643fadc73f385328dbfa75af7dcb3795.tar.bz2
seven-wonders-7499004f643fadc73f385328dbfa75af7dcb3795.zip
Actually enable STOMP heart beats
Diffstat (limited to 'sw-server/src/main')
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt11
1 files changed, 10 insertions, 1 deletions
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt
index dd4c4b15..1911f5b9 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt
@@ -5,6 +5,7 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.messaging.simp.config.ChannelRegistration
import org.springframework.messaging.simp.config.MessageBrokerRegistry
+import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker
import org.springframework.web.socket.config.annotation.StompEndpointRegistry
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
@@ -18,13 +19,21 @@ class WebSocketConfig(
override fun configureMessageBroker(config: MessageBrokerRegistry) {
// prefixes for all subscriptions
- config.enableSimpleBroker("/queue", "/topic")
+ config.enableSimpleBroker("/queue", "/topic").apply {
+ setTaskScheduler(createTaskScheduler()) // to support heart beats
+ }
config.setUserDestinationPrefix("/user")
// /app for normal calls, /topic for subscription events
config.setApplicationDestinationPrefixes("/app", "/topic")
}
+ private fun createTaskScheduler() = ThreadPoolTaskScheduler().apply {
+ poolSize = 1
+ threadNamePrefix = "stomp-heartbeat-thread-"
+ initialize()
+ }
+
override fun registerStompEndpoints(registry: StompEndpointRegistry) {
registry.addEndpoint(SEVEN_WONDERS_WS_ENDPOINT)
.setHandshakeHandler(handshakeHandler())
bgstack15