Skip to content
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

비관적 락 사용한 조회 호출 시, retry 매커니즘 적용 #296

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
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 @@ -57,6 +59,7 @@ public Page<BuyPriceToQuantityResponseDto> findAllBuyBidsOf(Product product, Pag
* @param price 구매를 원하는 상품 가격
* @return 구매입찰
*/
@Retryable(backoff = @Backoff(delay = 100))
public Buy getRecentBuyBidOf(Long productId, Long price) {
return buyRepository.findByProductIdAndPrice(productId, price, LocalDateTime.now())
.orElseThrow(() -> new GlobalException(BUY_BID_NOT_FOUND));
Expand Down
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