Browse Source

fix: 设计滑动库存分布式锁处理活动秒杀

seamew 2 năm trước cách đây
mục cha
commit
2d029bffe4

+ 0 - 1
lottery-application/pom.xml

@@ -16,7 +16,6 @@
             <groupId>com.seamew</groupId>
             <artifactId>lottery-domain</artifactId>
             <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
         </dependency>
 
         <!-- kafka依赖 -->

+ 16 - 16
lottery-interfaces/pom.xml

@@ -58,22 +58,22 @@
         </dependency>
 
         <!-- dubbo -->
-        <dependency>
-            <groupId>org.apache.dubbo</groupId>
-            <artifactId>dubbo</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.dubbo</groupId>
-            <artifactId>dubbo-spring-boot-starter</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.curator</groupId>
-            <artifactId>curator-framework</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.curator</groupId>
-            <artifactId>curator-recipes</artifactId>
-        </dependency>
+        <!--<dependency>-->
+        <!--    <groupId>org.apache.dubbo</groupId>-->
+        <!--    <artifactId>dubbo</artifactId>-->
+        <!--</dependency>-->
+        <!--<dependency>-->
+        <!--    <groupId>org.apache.dubbo</groupId>-->
+        <!--    <artifactId>dubbo-spring-boot-starter</artifactId>-->
+        <!--</dependency>-->
+        <!--<dependency>-->
+        <!--    <groupId>org.apache.curator</groupId>-->
+        <!--    <artifactId>curator-framework</artifactId>-->
+        <!--</dependency>-->
+        <!--<dependency>-->
+        <!--    <groupId>org.apache.curator</groupId>-->
+        <!--    <artifactId>curator-recipes</artifactId>-->
+        <!--</dependency>-->
 
         <!-- 三方工具包 -->
         <dependency>

+ 1 - 2
lottery-interfaces/src/main/java/com/seamew/lottery/LotteryApplication.java

@@ -1,6 +1,5 @@
 package com.seamew.lottery;
 
-import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
 import org.springframework.beans.factory.annotation.Configurable;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -16,8 +15,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
  */
 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
 @Configurable
-@EnableDubbo
 @EnableTransactionManagement
+// @EnableDubbo
 public class LotteryApplication {
     public static void main(String[] args) {
         SpringApplication.run(LotteryApplication.class, args);

+ 5 - 1
lottery-interfaces/src/main/java/com/seamew/lottery/interfaces/facade/LotteryActivityBooth.java

@@ -6,6 +6,7 @@ import com.seamew.lottery.application.process.req.DrawProcessReq;
 import com.seamew.lottery.application.process.res.DrawProcessResult;
 import com.seamew.lottery.application.process.res.RuleQuantificationCrowdResult;
 import com.seamew.lottery.common.Constants;
+import com.seamew.lottery.common.Result;
 import com.seamew.lottery.domain.rule.model.req.DecisionMatterReq;
 import com.seamew.lottery.domain.strategy.model.vo.DrawAwardVO;
 import com.seamew.lottery.interfaces.assembler.IMapping;
@@ -16,6 +17,8 @@ import com.seamew.lottery.rpc.req.QuantificationDrawReq;
 import com.seamew.lottery.rpc.res.DrawRes;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 
@@ -26,7 +29,7 @@ import javax.annotation.Resource;
  * @Description: 抽奖活动展台
  * @Version: 1.0
  */
-@Controller
+@RestController("/")
 @Slf4j
 public class LotteryActivityBooth implements ILotteryActivityBooth {
     @Resource
@@ -36,6 +39,7 @@ public class LotteryActivityBooth implements ILotteryActivityBooth {
     private IMapping<DrawAwardVO, AwardDTO> awardMapping;
 
     @Override
+    @RequestMapping("/doDraw")
     public DrawRes doDraw(DrawReq drawReq) {
         try {
             log.info("抽奖,开始 uId:{} activityId:{}", drawReq.getUId(), drawReq.getActivityId());

+ 16 - 16
lottery-interfaces/src/main/resources/application.yaml

@@ -1,5 +1,5 @@
 server:
-  port: 8080
+  port: 8085
 
 spring:
   kafka:
@@ -46,7 +46,7 @@ spring:
     host: 180.76.231.231
     port: 9736
     password: sunhaobo
-    timeout: 5000
+    timeout: 800
 
 # xxl-job
 # 官网:https://github.com/xuxueli/xxl-job/
@@ -95,20 +95,20 @@ mybatis:
     # 开启sql日志
     # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
-dubbo:
-  application:
-    name: Lottery
-    version: 1.0.0
-  registry:
-    address: zookeeper://180.76.231.231:2181
-    timeout: 60000
-  metadata-report:
-    address: zookeeper://180.76.231.231:2181
-  protocol:
-    name: dubbo
-    port: 20880
-  scan:
-    base-packages: com.seamew.lottery.rpc
+#dubbo:
+#  application:
+#    name: Lottery
+#    version: 1.0.0
+#  registry:
+#    address: zookeeper://180.76.231.231:2181
+#    timeout: 60000
+#  metadata-report:
+#    address: zookeeper://180.76.231.231:2181
+#  protocol:
+#    name: dubbo
+#    port: 20880
+#  scan:
+#    base-packages: com.seamew.lottery.rpc
 
 logging:
   level: