Skip to content

Commit

Permalink
[feat] #155 heartbeat 처리를 위한 스케줄러 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeesw committed Sep 23, 2024
1 parent 165773d commit 8d7039a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/com/book/backend/global/stomp/WebSocketConfig.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.book.backend.global.stomp;

import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
Expand Down Expand Up @@ -33,4 +35,14 @@ public void configureMessageBroker(final MessageBrokerRegistry registry) {
registry.enableSimpleBroker("/sub")// 구독요청
.setHeartbeatValue(new long[]{0, 10000}); // 클라이언트로부터 10초마다 ping 받는것으로 소켓 연결 유지
}

// heartbeat 처리를 위한 스케줄러
@Bean
public ThreadPoolTaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(1);
scheduler.setThreadNamePrefix("wss-heartbeat-thread-");
scheduler.initialize();
return scheduler;
}
}

0 comments on commit 8d7039a

Please sign in to comment.