-
Notifications
You must be signed in to change notification settings - Fork 0
fix: 재고 증가, 스케줄 락, 인프라 구축(Redis 클러스터링) #14
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
Conversation
|
|
||
| public interface StockOutboxRepository extends JpaRepository<StockOutbox, Long> { | ||
|
|
||
| @Query(value = "SELECT o FROM StockOutbox o WHERE o.status = :status ORDER BY o.createdAt LIMIT 100") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw e;
Uh oh!
There was an error while loading. Please reload this page.