File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
src/main/java/clap/server/adapter/outbound/infrastructure/elastic/scheduler Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ package clap .server .adapter .outbound .infrastructure .elastic .scheduler ;
2+
3+ import co .elastic .clients .elasticsearch .ElasticsearchClient ;
4+ import lombok .RequiredArgsConstructor ;
5+ import lombok .extern .slf4j .Slf4j ;
6+ import org .springframework .scheduling .annotation .Scheduled ;
7+ import org .springframework .stereotype .Component ;
8+
9+ @ Component
10+ @ RequiredArgsConstructor
11+ @ Slf4j
12+ public class ElasticsearchConnectionScheduler {
13+ private final ElasticsearchClient client ;
14+
15+ @ Scheduled (fixedRate = 30000 )
16+ public void keepConnectionAlive () {
17+ try {
18+ if (!client .ping ().value ()) {
19+ log .error ("Elasticsearch 연결 실패" );
20+ }
21+ } catch (Exception e ) {
22+ log .error ("Elasticsearch 연결 중 예외 발생: {}" , e .getMessage ());
23+ }
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments