ソースを参照

移除延迟队列

why 3 年 前
コミット
d64758c530

BIN
lib/smart-redisson-spring-boot-starter.jar


+ 0 - 15
pom.xml

@@ -156,20 +156,6 @@
             <artifactId>spring-boot-starter-data-redis</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>riven</groupId>
-            <artifactId>smart-redisson-spring-boot-starter</artifactId>
-            <version>1.1.6</version>
-            <scope>system</scope>
-            <systemPath>${basedir}/lib/smart-redisson-spring-boot-starter.jar</systemPath>
-        </dependency>
-
-        <!--<dependency>-->
-        <!--    <groupId>cn.hutool</groupId>-->
-        <!--    <artifactId>hutool-all</artifactId>-->
-        <!--    <version>5.7.22</version>-->
-        <!--</dependency>-->
-
     </dependencies>
 
     <build>
@@ -179,7 +165,6 @@
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
                 <configuration>
-                    <includeSystemScope>true</includeSystemScope>
                     <excludes>
                         <exclude>
                             <groupId>org.projectlombok</groupId>

+ 0 - 47
src/main/java/com/td/boss/config/delay/RedissonDelayTask.java

@@ -1,47 +0,0 @@
-package com.td.boss.config.delay;
-
-import com.alibaba.fastjson.JSONObject;
-import com.riven.redisson.annotation.EnableRedisson;
-import com.riven.redisson.annotation.RedissonListener;
-import com.riven.redisson.config.RedissonQueue;
-import com.riven.redisson.exception.MessageConversionException;
-import com.riven.redisson.message.*;
-import com.td.boss.config.delay.pojo.PlayerGoods;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.messaging.handler.annotation.Header;
-import org.springframework.messaging.handler.annotation.Payload;
-
-import java.util.Map;
-
-/**
- * redisson延迟任务
- *
- * @author why
- * @date 2022/03/22
- */
-@Configuration
-@EnableRedisson
-public class RedissonDelayTask {
-    @Bean
-    public RedissonQueue redissonQueue() {
-        return new RedissonQueue("playerGoods", true, null, playerGoodsMessageConverter());
-    }
-    @Bean("playerGoodsMessageConverter")
-    public MessageConverter playerGoodsMessageConverter() {
-        return new MessageConverter() {
-            @Override
-            public QueueMessage<?> toMessage(Object object, Map<String, Object> headers) throws MessageConversionException {
-                //do something you want, eg:
-                headers.put("my_header", "my_header_value");
-                return QueueMessageBuilder.withPayload(object).headers(headers).build();
-            }
-
-            @Override
-            public Object fromMessage(RedissonMessage redissonMessage) throws MessageConversionException {
-                Object payload = redissonMessage.getPayload();
-                return JSONObject.parseObject(payload.toString(), PlayerGoods.class);
-            }
-        };
-    }
-}

+ 0 - 20
src/main/java/com/td/boss/config/delay/pojo/PlayerGoods.java

@@ -1,20 +0,0 @@
-package com.td.boss.config.delay.pojo;
-
-import lombok.Data;
-
-import java.io.Serializable;
-
-/**
- * 仓库断电损耗延迟队列
- *
- * @author why
- * @date 2022/03/22
- */
-@Data
-public class PlayerGoods implements Serializable {
-    /**
-     * 用户id
-     */
-    private String userId;
-
-}

+ 0 - 19
src/main/java/com/td/boss/config/delay/pojo/Withered.java

@@ -1,19 +0,0 @@
-package com.td.boss.config.delay.pojo;
-
-import lombok.Data;
-
-import java.io.Serializable;
-
-/**
- * 枯萎延迟队列
- *
- * @author why
- * @date 2022/03/22
- */
-@Data
-public class Withered implements Serializable {
-    /**
-     * 用户id
-     */
-    private String userId;
-}

+ 2 - 49
src/main/java/com/td/boss/game/complayergoods/service/ComPlayerGoodsServiceImpl.java

@@ -1,18 +1,11 @@
 package com.td.boss.game.complayergoods.service;
 
-import com.riven.redisson.annotation.RedissonListener;
-import com.riven.redisson.message.RedissonHeaders;
-import com.td.boss.common.service.*;
-import com.td.boss.config.delay.pojo.PlayerGoods;
+import com.td.boss.common.service.CommonServiceImpl;
 import com.td.boss.game.complayergoods.pojo.ComPlayerGoods;
-import com.td.boss.game.complayergoods.vo.ComPlayerGoodsSimpleVo;
+import com.td.boss.game.complayergoods.repository.ComPlayerGoodsRepository;
 import com.td.boss.game.complayergoods.vo.ComPlayerGoodsTypeSumVo;
 import com.td.boss.game.complayergoods.vo.ComPlayerGoodsVo;
-import com.td.boss.game.complayergoods.repository.ComPlayerGoodsRepository;
-import com.td.boss.util.CopyUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.messaging.handler.annotation.Header;
-import org.springframework.messaging.handler.annotation.Payload;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -47,44 +40,4 @@ public class ComPlayerGoodsServiceImpl extends CommonServiceImpl<ComPlayerGoodsV
     public List<ComPlayerGoodsTypeSumVo> findAllGroupByGoodsType() {
         return comPlayerGoodsRepository.findAmountSumByGoodsType();
     }
-
-    /**
-     * 处理仓库断电损耗 延迟任务
-     *
-     * @param messageId           消息id
-     * @param queue               队列
-     * @param sendTimestamp       发送时间戳
-     * @param expectedDelayMillis 预计延迟
-     * @param myHeader            头
-     * @param playerGoods         玩家物品
-     */
-    @RedissonListener(queues = "playerGoods", messageConverter = "playerGoodsMessageConverter")
-    public void handler(@Header(value = RedissonHeaders.MESSAGE_ID, required = false) String messageId,
-                        @Header(RedissonHeaders.DELIVERY_QUEUE_NAME) String queue,
-                        @Header(RedissonHeaders.SEND_TIMESTAMP) long sendTimestamp,
-                        @Header(RedissonHeaders.EXPECTED_DELAY_MILLIS) long expectedDelayMillis,
-                        @Header(value = "my_header", required = false, defaultValue = "test") String myHeader,
-                        @Payload PlayerGoods playerGoods) {
-        /**
-         *         1.注入
-         *         @Autowired
-         *         private RedissonTemplate redissonTemplate;
-         *
-         *         2.像队列中添加延迟任务
-         *         PlayerGoods playerGoods = new PlayerGoods();
-         *         playerGoods.setUserId("1002");
-         *         redissonTemplate.sendWithDelay("playerGoods", playerGoods, 10000);
-         */
-
-        System.out.println(messageId);
-        System.out.println(queue);
-        System.out.println(myHeader);
-        long actualDelay = System.currentTimeMillis() - (sendTimestamp + expectedDelayMillis);
-        System.out.println("receive " + playerGoods + ", delayed " + actualDelay + " millis");
-
-        List<ComPlayerGoods> allByUserId = comPlayerGoodsRepository.findAllByUserId(playerGoods.getUserId());
-        System.out.println("查一下:" + allByUserId);
-        System.out.println(allByUserId);
-
-    }
 }