Open
Conversation
BinaryContent의 상태를 업데이트하는 메서드를 정의하는 것까지 했습니다.
BinaryContentCreatedEventListener의 이벤트 리스너에 시험삼아 condition으로 조건을 걸어봤습니다.
채널에 새로운 메시지가 등록된 경우 알림을 받을 수 있도록 리팩토링하세요.
- MessageCreatedEvent를 정의하고 새로운 메시지가 등록되면 이벤트를 발행하세요.
- 사용자 별로 관심있는 채널의 알림만 받을 수 있도록 ReadStatus 엔티티에 채널 알림 여부 속성(notificationEnabled)을 추가하세요.
- PRIVATE 채널은 알림 여부를 true로 초기화합니다.
- PUBLIC 채널은 알림 여부를 false로 초기화합니다.
- 알림 여부를 수정할 수 있게 ReadStatusUpdateRequest를 수정하세요.
[ ] 사용자의 권한(Role)이 변경된 경우 알림을 받을 수 있도록 리팩토링하세요. [ ] 알림 API를 구현하세요. * 요청자 본인의 알림에 대해서만 수행할 수 있습니다. << fix 해야함 [ ] 알림이 필요한 이벤트가 발행되었을 때 알림을 생성하세요.
* TaskDecorator 수정 필요
* 재시도가 모두 실패했을 때 대응전략 수정 필요
spring-kang
reviewed
Nov 5, 2025
| } | ||
|
|
||
| // 트랜잭션이 commit되었을 때 실행 | ||
| @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) |
Collaborator
There was a problem hiding this comment.
TransactionPhase.AFTER_COMMIT 가 default 설정인데 이렇게 해두신것은 의도를 표현하기 위함인가요?
spring-kang
reviewed
Nov 5, 2025
|
|
||
| @Transactional | ||
| @Override | ||
| public UserDto updateRoleInternal(RoleUpdateRequest request) { |
Collaborator
There was a problem hiding this comment.
해당 로직에서도 이벤트 발행이 필요해보이는데 누락된것 같습니다 !
spring-kang
reviewed
Nov 5, 2025
| @Bean(name = "taskExecutor") | ||
| public Executor taskExecutor() { | ||
| // TaskDecorator는 인터페이스다 | ||
| CustomTaskDecorator decorator = new CustomTaskDecorator(); |
Collaborator
There was a problem hiding this comment.
파라미터로 필요한 정보 추가로 넣어주시면 좋을것 같습니다 !
spring-kang
reviewed
Nov 5, 2025
|
|
||
| @Configuration | ||
| @EnableAsync | ||
| public class AsyncConfig implements AsyncConfigurer { |
Collaborator
There was a problem hiding this comment.
설정은 잘하셨는데 어노테이션으로 적용하는 부분이 없는것 같습니다. 요구사항에 맞춰 어노테이션을 적용해보시면 좋을것 같습니다.
spring-kang
reviewed
Nov 5, 2025
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| @EnableRetry |
Collaborator
There was a problem hiding this comment.
RetryConfig 보다는 AppConfig라고 명명하고 추후 앱관련 공통설정은 여기다 몰아넣는게 좋은것 같아요!
spring-kang
approved these changes
Nov 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요구사항
기본
Spring Event - 파일 업로드 로직 분리하기
`-- schema.sql
CREATE TABLE binary_contents
(
id uuid PRIMARY KEY,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone,
file_name varchar(255) NOT NULL,
size bigint NOT NULL,
content_type varchar(100) NOT NULL,
status varchar(20) NOT NULL
);
-- ALTER TABLE binary_contents
-- ADD COLUMN updated_at timestamp with time zone;
-- ALTER TABLE binary_contents
`
Spring Event - 알림 기능 추가하기
`-- schema.sql
CREATE TABLE read_statuses
(
id uuid PRIMARY KEY,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone,
user_id uuid NOT NULL,
channel_id uuid NOT NULL,
last_read_at timestamp with time zone NOT NULL,
notification_enabled boolean NOT NULL,
UNIQUE (user_id, channel_id)
);
-- ALTER TABLE read_statuses
-- ADD COLUMN notification_enabled boolean NOT NULL;
`
알림 여부를 수정할 수 있게 ReadStatusUpdateRequest를 수정하세요.
사용자의 권한(Role)이 변경된 경우 알림을 받을 수 있도록 리팩토링하세요.
알림 API를 구현하세요.
NotificationDto를 정의하세요.
알림 조회
알림 확인
알림이 필요한 이벤트가 발행되었을 때 알림을 생성하세요.
`public class NotificationRequiredEventListener {
@TransactionalEventListener
public void on(MessageCreatedEvent event) {...}
@TransactionalEventListener
public void on(RoleUpdatedEvent event) {...}
}`
해당 채널의 알림 여부를 활성화한 ReadStatus를 조회합니다.
해당 ReadStatus의 사용자들에게 알림을 생성합니다.
단, 해당 메시지를 보낸 사람은 알림 대상에서 제외합니다.
on(RoleUpdatedEvent)
심화
주요 변경사항
스크린샷
멘토에게