Skip to content

Commit

Permalink
test: 처리하지 못한 pending 메세지 처리 테스트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
seungh1024 committed May 17, 2024
1 parent 332fe3e commit cd921e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void claimMessage(PendingMessage pendingMessage, String streamKey, String
CommandArgs<String, String> commandArgs = new CommandArgs<>(StringCodec.UTF8).addKey(streamKey)
.add(pendingMessage.getGroupName())
.add(consumerName)
.add("3000") // 3초 이상 pending된 메세지만 처리한다
.add("3000")
.add(pendingMessage.getIdAsString());

commands.dispatch(CommandType.XCLAIM, new StatusOutput<>(StringCodec.UTF8), commandArgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ void accountInit() {
createPendingMessage();
}

// @BeforeEach()
// void initPendingMessage() {
// createPendingMessage();
// }

@AfterEach
void accountClear() {
clearAccount();
Expand Down Expand Up @@ -119,11 +114,13 @@ void not_consumed_pending_message_will_rollback() throws InterruptedException {
// Given
MainAccount sendAccount = mainAccountRepository.findById(mainAccountPk[0]).get();
long originMoney = sendAccount.getMoney();
// 3초 이상 된 메세지만 claim 처리를 하므로 3초 기다린다
executor.getThreadPoolExecutor().awaitTermination(3, TimeUnit.SECONDS);

// When
executor.initialize();
pendingMessageScheduler.consumeClaimMessage();
executor.getThreadPoolExecutor().awaitTermination(15, TimeUnit.SECONDS);
executor.getThreadPoolExecutor().awaitTermination(10, TimeUnit.SECONDS);

// Then
MainAccount rollBackMember = mainAccountRepository.findById(mainAccountPk[0]).get();
Expand Down

0 comments on commit cd921e1

Please sign in to comment.