Skip to content

Commit

Permalink
refactor : SellQueryService 에서 비관적 락 사용한 조회 호출 시, retry 매커니즘 적용
Browse files Browse the repository at this point in the history
- @retryable 적용
- delay 100ms 설정
  • Loading branch information
vanillacake369 committed Mar 17, 2024
1 parent 0c85a1a commit 2c47aa2
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
import bc1.gream.domain.sell.repository.SellRepository;
import bc1.gream.domain.user.entity.User;
import bc1.gream.global.exception.GlobalException;
import java.time.LocalDateTime;
import bc1.gream.global.redis.RedisCacheName;
import bc1.gream.global.redis.RestPage;
import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand Down Expand Up @@ -50,6 +52,7 @@ public Sell findByIdAndUser(Long sellId, User user) {
}

@Transactional(readOnly = true)
@Retryable(backoff = @Backoff(delay = 100))
public Sell getRecentSellBidof(Long productId, Long price) {
return sellRepository.findByProductIdAndPrice(productId, price, LocalDateTime.now()).orElseThrow(
() -> new GlobalException(SELL_BID_PRODUCT_NOT_FOUND)
Expand Down

0 comments on commit 2c47aa2

Please sign in to comment.