Skip to content

Commit

Permalink
Feat/sse (#111)
Browse files Browse the repository at this point in the history
* Fix: 오류 수정

* Fix: 구독 목록 불러오기 수정

* Fix: transactional readonly 삭제

* Fix: sse 연결 방식 수정

* Remove: pub/sub 파일 삭제

* Feat: ExecutorService 추가

* Fix: api 수정

* Fix: sse 데이터 전달 테스트
  • Loading branch information
flowerdonk authored Aug 14, 2023
1 parent 4c63f42 commit ef3ba2a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class AlarmController {

@GetMapping(produces = "text/event-stream")
public ResponseEntity<SseEmitter> createEmitter(@AuthenticationPrincipal OAuth2User oAuth2User,
@RequestHeader(value = "Last-Event_ID", required = false) String lastEventId, HttpServletResponse response) {
@RequestHeader(value = "Last-Event_ID", required = false) String lastEventId) {

return new ResponseEntity<>(alarmService.createEmitter(oAuth2User, lastEventId, LocalDateTime.now()), HttpStatus.OK);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/anywayclear/controller/DibController.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public ResponseEntity<Void> createDib(@PathVariable Long produceId, @Authenticat
return ResponseEntity.created(URI.create("/api/dibs/" + id)).build();
}

@GetMapping("/{dib-id}")
@GetMapping("/dib/{dib-id}")
public ResponseEntity<DibResponse> getDib(@PathVariable("dib-id") Long dibId) {
return ResponseEntity.ok(dibService.getDib(dibId));
}

@GetMapping("/{userId}")
@GetMapping("/user/{userId}")
public ResponseEntity<MultiResponse<DibResponse, Dib>> getDibList(@PathVariable("userId") String userId, Pageable pageable) {
return ResponseEntity.ok(dibService.getDibPage(userId, pageable));
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/anywayclear/service/AlarmService.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,14 @@ public void sendToClient(SseEmitter emitter, String key, String name, Object dat
.id(key)
.name(name)
.data(data));
log.info("data 전달 성공");
emitter.send("더미 데이터");
log.info("더미데이터 전달 성공");
} catch (IOException e) {
sseRepository.remove(key);
log.info("예외 발생");
}
emitter.complete();
});
}
}

0 comments on commit ef3ba2a

Please sign in to comment.