-
Notifications
You must be signed in to change notification settings - Fork 16
[신은수] Sprint11 #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 신은수
Are you sure you want to change the base?
[신은수] Sprint11 #161
Conversation
|
|
||
| private final BinaryContentAsyncWorker binaryContentAsyncWorker; | ||
|
|
||
| @EventListener |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TransactionalEventListener 를 안쓰고 EventListener를 활용한 의도가 있으신가요?
| BinaryContent binaryContent = new BinaryContent(fileName, (long) bytes.length, | ||
| contentType); | ||
| binaryContentRepository.save(binaryContent); | ||
| eventPublisher.publishEvent(new BinaryContentCreatedEvent(binaryContent.getId(), bytes, fileName, contentType)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여긴 메시지 관련 이벤트에 대한 발행 로직이 들어가야할 것 같습니다.
| @Bean(name = {"taskExecutor", "applicationTaskExecutor"}) | ||
| public Executor taskExecutor(TaskDecorator mdcSecurityContextTaskDecorator) { | ||
| ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | ||
| // 운영 환경에 맞게 조정하세요. | ||
| executor.setCorePoolSize(4); | ||
| executor.setMaxPoolSize(16); | ||
| executor.setQueueCapacity(1000); | ||
| executor.setThreadNamePrefix("async-"); | ||
| executor.setTaskDecorator(mdcSecurityContextTaskDecorator); | ||
| executor.initialize(); | ||
| return executor; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이게 더 먼저 선언되면 가독성이 올라갈것 같습니다.
| private final BinaryContentStorage binaryContentStorage; | ||
| private final BinaryContentService binaryContentService; | ||
|
|
||
| @Async |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
빈으로 설정해둔 executor를 명시해주세요.
|
|
||
| @Configuration | ||
| @EnableRetry | ||
| public class RetryConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppConfig를 추가하고 여기에 공통된 기능들을 모으는게 더 자연스러울것 같습니다.
| } | ||
|
|
||
| log.error("S3 업로드 최종 실패(재시도 모두 소진): key={}, reason={}", key, errorMessage, e); | ||
| throw new RuntimeException("S3에 파일 업로드 실패(최종): " + key, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cusotom exception으로 처리하시는것도 좋을것 같습니다.
요구사항
기본
Spring Event - 파일 업로드 로직 분리하기
BinaryContent에 바이너리 데이터 업로드 상태 속성(status)을 추가하세요.
PROCESSING: 업로드 중
SUCCESS: 업로드 완료
FAIL: 업로드 실패
BinaryContent의 상태를 업데이트하는 메소드를 정의하세요.
Spring Event - 알림 기능 추가하기
비동기 적용하기
비동기 실패 처리하기
# 알림 내용 예시 RequestId: 7641467e369e458a98033558a83321fb BinaryContentId: b0549c2a-014c-4761-8b21-4b77d3bd011c Error: The AWS Access Key Id you provided does not exist in our records. (Service: S3, Status Code: 403, Request ID: B7KCVSRCGPYJZREX, Extended Request ID: AWRVuJJJ3upwwOkCnd+yhHkgSajUxdg7L4195lbMVTIka6WnBpjZLLRTReoHbgIMf9zzH/QQM0Y5ZOVJCHF2F+l2mSyPG/+8Ee2XBS8hcqk=) (SDK Attempt Count: 1)캐시 적용하기
심화
주요 변경사항
스크린샷
멘토에게