Skip to content

Commit

Permalink
Merge pull request #222 from bucket-back/OMCT-408-alarm-sse
Browse files Browse the repository at this point in the history
[OMCT-408] emitter 생명주기를 짧게 수정함, securityConfiguration에 subscribe 예외 처리
  • Loading branch information
HandmadeCloud authored Jan 10, 2024
2 parents 4e1a308 + 68b64f8 commit 20a56ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@
@Component
public class SseEmitters {

private static final Long DEFAULT_TIMEOUT = 30 * 60 * 1000L; // 60분
private static final Long DEFAULT_TIMEOUT = 25 * 1000L; //25초
private final Map<Long, SseEmitter> emitters = new ConcurrentHashMap<>();

public SseEmitter add(final Long receiverId) {
SseEmitter sseEmitter = new SseEmitter(DEFAULT_TIMEOUT);

this.emitters.put(receiverId, sseEmitter);
sseEmitter.onTimeout(sseEmitter::complete);
sseEmitter.onCompletion(() -> this.emitters.remove(receiverId));
sseEmitter.onError((e) -> this.emitters.remove(receiverId));
sseEmitter.onError((e) -> {
log.error("error with emitter");
this.emitters.remove(receiverId);
});

return sseEmitter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public SecurityFilterChain securityFilterChain(final HttpSecurity http) throws E
.requestMatchers("/api/{nickname}/buckets/**").permitAll()

.requestMatchers("/api/hobbies").permitAll()
.requestMatchers("/api/sse/subscribe").permitAll()

.anyRequest().authenticated()
)
Expand Down

0 comments on commit 20a56ef

Please sign in to comment.