Skip to content

Conversation

@sangyunpark99
Copy link
Collaborator

@sangyunpark99 sangyunpark99 commented May 8, 2025

image image

@sangyunpark99 sangyunpark99 requested a review from f-lab-nolan May 8, 2025 01:14
@sangyunpark99 sangyunpark99 changed the title Fix/13 product fix: 재고 증가, 스케줄 락, 인프라 구축(Redis 클러스터링) May 8, 2025

public interface StockOutboxRepository extends JpaRepository<StockOutbox, Long> {

@Query(value = "SELECT o FROM StockOutbox o WHERE o.status = :status ORDER BY o.createdAt LIMIT 100")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SELECT o.* FROM StockOutbox o WHERE o.status = :status ORDER BY o.createdAt LIMIT 100

List<StockOutbox> findPendingOutboxEvent(@Param("status") OutboxStatus status, LocalDateTime createdAt);

@Modifying(clearAutomatically = true)
@Query("UPDATE StockOutbox o SET o.status = :status, o.updatedAt = :updatedAt WHERE o.id IN :ids")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UPDATE StockOutbox SET status = :status, updatedAt = :updatedAt WHERE id IN :ids

try {
remainStock = stockRedisRepository.decrease(productId, quantity);
} catch (Exception e) {
log.error("Redis 재고 감소 실패: productId={}, quantity={}, orderId={}", productId, quantity, orderId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        log.error("Redis 재고 감소 실패: productId={}, quantity={}, orderId={}", productId, quantity, orderId, e);

remainStock = stockRedisRepository.decrease(productId, quantity);
} catch (Exception e) {
log.error("Redis 재고 감소 실패: productId={}, quantity={}, orderId={}", productId, quantity, orderId);
throw new BusinessException(ErrorCode.INTERNAL_SERVER_ERROR);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw e;

@sangyunpark99 sangyunpark99 merged commit de844bb into develop May 13, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants