Skip to content

Commit

Permalink
Merge pull request #37 from SQUAD-D/feature#18/image-update
Browse files Browse the repository at this point in the history
chore
  • Loading branch information
songhaechan authored Jul 6, 2024
2 parents 123ff8e + cfebdf2 commit 858ff41
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/java/squad/board/service/BoardService.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public CommonIdResponse createBoard(Long memberId, CreateBoardRequest createBoar
// 이미지 정보 저장
if (createBoard.isImageExist()) {
imageMapper.save(createBoard.getImageInfo(), board.getBoardId());
deadLetterQueue.pushAll(createBoard.getImageInfo().stream()
messageQueue.pushAll(createBoard.getImageInfo().stream()
.map(ImageInfoRequest::getImageUUID)
.toList());
}
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/squad/board/service/S3Consumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ public class S3Consumer {
private final S3MailSender s3MailSender;
private final String MAIL_CONTENT = "The dead letter queue has exceeded its maximum allowable size.";

// @Scheduled(fixedDelay = 1000)
// public void normalConsume() {
// while (!messageQueue.isEmpty()) {
// String uuid = messageQueue.pop();
// try {
// s3Service.moveImageToOriginal(uuid);
// } catch (AmazonServiceException e) {
// deadLetterQueue.push(uuid);
// }
// }
// }
@Scheduled(fixedDelay = 1000)
public void normalConsume() {
while (!messageQueue.isEmpty()) {
String uuid = messageQueue.pop();
try {
s3Service.moveImageToOriginal(uuid);
} catch (AmazonServiceException e) {
deadLetterQueue.push(uuid);
}
}
}

@Scheduled(fixedDelay = 2000)
public void deadLetterConsume() {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/squad/board/service/S3DeadLetterQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ public class S3DeadLetterQueue {

private static final String MESSAGE_QUEUE = "s3_dead_letter";
private static final int EMPTY = 0;
private static final int LIMIT = 3;
private static final int LIMIT = 30;
private final RedisTemplate<String, Object> redisTemplate;

public void push(String uuid) {
redisTemplate.opsForList().leftPush(MESSAGE_QUEUE, uuid);
}

public void pushAll(List<String> imageUUID) {
for (String uuid : imageUUID)
redisTemplate.opsForList().leftPushAll(MESSAGE_QUEUE, uuid);
Expand Down

0 comments on commit 858ff41

Please sign in to comment.