-
Notifications
You must be signed in to change notification settings - Fork 16
[김이준] Sprint11 #149
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: main
Are you sure you want to change the base?
[김이준] Sprint11 #149
Conversation
This reverts commit e0752c4.
| .orElseThrow(() -> ChannelNotFoundException.withId(channelId)); | ||
| } | ||
|
|
||
| @Cacheable(value = "userChannelsCache", key = "#userId") |
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 ObjectMapper objectMapper; | ||
|
|
||
| @KafkaListener(topics = "discodeit.MessageCreatedEvent") | ||
| @CacheEvict(value = "userNotificationsCache", allEntries = true) |
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.
캐시 eviction 설정
| ); | ||
| binaryContentRepository.save(binaryContent); | ||
|
|
||
| publisher.publishEvent(new BinaryContentCreatedEvent(binaryContent.getId(), bytes)); |
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; | ||
|
|
||
| @Async | ||
| @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) |
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.
이벤트 소비
| binaryContentStorage.put(event.id(), event.bytes()); | ||
| binaryContentService.updateStatus(event.id(), BinaryContentStatus.SUCCESS); | ||
| } catch (Exception e) { | ||
| log.error("Binary Content 저장 실패: ", e); | ||
| binaryContentService.updateStatus(event.id(), BinaryContentStatus.FAIL); |
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.
상태 변경 처리
| jwtRegistry.invalidateJwtInformationByUserId(userId); | ||
|
|
||
| if (!pastRole.equals(newRole)) { | ||
| publisher.publishEvent(new RoleUpdatedEvent(pastRole, user)); |
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.
이벤트 발행
| @Async | ||
| @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
| public void on(MessageCreatedEvent event) throws JsonProcessingException { | ||
| String payload = objectMapper.writeValueAsString(event); | ||
| kafkaTemplate.send("discodeit.MessageCreatedEvent", payload); | ||
| } | ||
|
|
||
| @Async | ||
| @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
| public void on(RoleUpdatedEvent event) throws JsonProcessingException { | ||
| String payload = objectMapper.writeValueAsString(event); | ||
| kafkaTemplate.send("discodeit.RoleUpdatedEvent", payload); | ||
|
|
||
| } | ||
|
|
||
| @Async | ||
| @EventListener | ||
| public void on(BinaryContentRecoverEvent event) throws JsonProcessingException { | ||
| String requestId = MDC.get("REQUEST_ID"); | ||
| String payload = objectMapper.writeValueAsString(event); |
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.
카프카 이벤트 소비
| @Configuration | ||
| @EnableJpaAuditing | ||
| @EnableScheduling | ||
| @EnableCaching | ||
| @EnableRetry |
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.
Retry 설정은 됐으나 누락
| @Timed("message.create.async") | ||
| @PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE) | ||
| public ResponseEntity<MessageDto> create( | ||
| @RequestPart("messageCreateRequest") @Valid MessageCreateRequest messageCreateRequest, | ||
| @RequestPart(value = "attachments", required = false) List<MultipartFile> attachments | ||
| ) { | ||
| log.info("메시지 생성 요청: request={}, attachmentCount={}", | ||
| messageCreateRequest, attachments != null ? attachments.size() : 0); | ||
|
|
||
| List<BinaryContentCreateRequest> attachmentRequests = Optional.ofNullable(attachments) |
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.
Timed 설정됨
|
|
||
| // CacheConfig | ||
| @Bean | ||
| public RedisCacheConfiguration redisCacheConfiguration(ObjectMapper objectMapper) { |
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.
레디스 캐시 설정
기본 요구사항
Spring Event - 파일 업로드 로직 분리하기
Spring Event - 알림 기능 추가하기
비동기 적용하기
비동기 실패 처리하기
캐시 적용하기
심화 요구사항
Spring Kafka 도입하기
Redis Cache 도입하기