Search in sources :

Example 1 with BetaTrace

use of com.actionworks.flashsale.config.annotion.BetaTrace in project flash-sale by ThoughtsBeta.

the class FlashItemWarmUpScheduler method warmUpFlashItemTask.

@Scheduled(cron = "*/5 * * * * ?")
@BetaTrace
public void warmUpFlashItemTask() {
    logger.info("warmUpFlashItemTask|秒杀品预热调度");
    PagesQueryCondition pagesQueryCondition = new PagesQueryCondition();
    pagesQueryCondition.setStockWarmUp(0);
    PageResult<FlashItem> pageResult = flashItemDomainService.getFlashItems(pagesQueryCondition);
    pageResult.getData().forEach(flashItem -> {
        boolean initSuccess = itemStockCacheService.alignItemStocks(flashItem.getId());
        if (!initSuccess) {
            logger.info("warmUpFlashItemTask|秒杀品库存已经初始化预热失败", flashItem.getId());
            return;
        }
        flashItem.setStockWarmUp(1);
        flashItemDomainService.publishFlashItem(flashItem);
        logger.info("warmUpFlashItemTask|秒杀品库存已经初始化预热成功", flashItem.getId());
    });
}
Also used : FlashItem(com.actionworks.flashsale.domain.model.entity.FlashItem) PagesQueryCondition(com.actionworks.flashsale.domain.model.PagesQueryCondition) Scheduled(org.springframework.scheduling.annotation.Scheduled) BetaTrace(com.actionworks.flashsale.config.annotion.BetaTrace)

Example 2 with BetaTrace

use of com.actionworks.flashsale.config.annotion.BetaTrace in project flash-sale by ThoughtsBeta.

the class StocksAlignScheduler method alignStocksTask.

@Scheduled(cron = "*/2 * * * * ?")
@BetaTrace
public void alignStocksTask() {
    logger.info("alignStocksTask|校准库存缓存开始");
    PagesQueryCondition pagesQueryCondition = new PagesQueryCondition();
    pagesQueryCondition.setStatus(FlashItemStatus.ONLINE.getCode());
    PageResult<FlashItem> pageResult = flashItemDomainService.getFlashItems(pagesQueryCondition);
    pageResult.getData().forEach(flashItem -> {
        boolean result = itemStockCacheService.alignItemStocks(flashItem.getId());
        if (!result) {
            logger.info("alignStocksTask|库存校准失败", flashItem.getId(), flashItem.getAvailableStock());
            return;
        }
        logger.info("alignStocksTask|库存校准完成", flashItem.getId(), flashItem.getAvailableStock());
    });
    logger.info("alignStocksTask|校准库存缓存结束");
}
Also used : FlashItem(com.actionworks.flashsale.domain.model.entity.FlashItem) PagesQueryCondition(com.actionworks.flashsale.domain.model.PagesQueryCondition) Scheduled(org.springframework.scheduling.annotation.Scheduled) BetaTrace(com.actionworks.flashsale.config.annotion.BetaTrace)

Aggregations

BetaTrace (com.actionworks.flashsale.config.annotion.BetaTrace)2 PagesQueryCondition (com.actionworks.flashsale.domain.model.PagesQueryCondition)2 FlashItem (com.actionworks.flashsale.domain.model.entity.FlashItem)2 Scheduled (org.springframework.scheduling.annotation.Scheduled)2