xiongzhu há 3 anos atrás
pai
commit
b7972ea681

+ 1 - 1
src/main/java/com/izouma/nineth/listener/OrderNotifyListener.java

@@ -16,7 +16,7 @@ import org.springframework.stereotype.Service;
 @RocketMQMessageListener(
         consumerGroup = "${general.order-notify-group}",
         topic = "${general.order-notify-topic}",
-        consumeMode = ConsumeMode.CONCURRENTLY)
+        consumeMode = ConsumeMode.ORDERLY)
 @ConditionalOnProperty(value = "general.notify-server", havingValue = "true")
 public class OrderNotifyListener implements RocketMQListener<OrderNotifyEvent> {
     private OrderService orderService;

+ 8 - 0
src/main/java/com/izouma/nineth/service/CollectionService.java

@@ -31,6 +31,8 @@ import org.springframework.data.domain.Sort;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.data.redis.core.BoundValueOperations;
 import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.retry.annotation.Backoff;
+import org.springframework.retry.annotation.Retryable;
 import org.springframework.scheduling.TaskScheduler;
 import org.springframework.stereotype.Service;
 
@@ -285,7 +287,13 @@ public class CollectionService {
                 .build());
     }
 
+    @Retryable(value = {BusinessException.class}, maxAttempts = 3, backoff = @Backoff(delay = 1000))
     public synchronized BlindBoxItem draw(Long collectionId) {
+//        BoundValueOperations<String, Object> ops = redisTemplate.boundValueOps("draw::" + collectionId);
+//        if (ops.get() == null) {
+//            Boolean success = ops.setIfAbsent(blindBoxItemRepo.findByBlindBoxId(collectionId), 7, TimeUnit.DAYS);
+//            log.info("抽盲盒缓存 {} {}", collectionId, success);
+//        }
         long t = System.currentTimeMillis();
         List<BlindBoxItem> items = blindBoxItemRepo.findByBlindBoxId(collectionId);