From 4d02466fed4f3ea012a80c3359cde9af0737141f Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期一, 21 十一月 2022 20:01:12 +0800 Subject: [PATCH] add 增加 skywalking 集成 默认注释不开启 --- ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/QueueUtils.java | 118 +++++++++++++++++++---------------------------------------- 1 files changed, 38 insertions(+), 80 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/QueueUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/QueueUtils.java index 7850e01..7a4bce4 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/QueueUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/QueueUtils.java @@ -5,7 +5,6 @@ import lombok.NoArgsConstructor; import org.redisson.api.*; -import java.util.Comparator; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; @@ -28,6 +27,43 @@ */ public static RedissonClient getClient() { return CLIENT; + } + + /** + * 娣诲姞鏅�氶槦鍒楁暟鎹� + * + * @param queueName 闃熷垪鍚� + * @param data 鏁版嵁 + */ + public static <T> boolean addQueueObject(String queueName, T data) { + RBlockingQueue<T> queue = CLIENT.getBlockingQueue(queueName); + return queue.offer(data); + } + + /** + * 閫氱敤鑾峰彇涓�涓槦鍒楁暟鎹� 娌℃湁鏁版嵁杩斿洖 null(涓嶆敮鎸佸欢杩熼槦鍒�) + * + * @param queueName 闃熷垪鍚� + */ + public static <T> T getQueueObject(String queueName) { + RBlockingQueue<T> queue = CLIENT.getBlockingQueue(queueName); + return queue.poll(); + } + + /** + * 閫氱敤鍒犻櫎闃熷垪鏁版嵁(涓嶆敮鎸佸欢杩熼槦鍒�) + */ + public static <T> boolean removeQueueObject(String queueName, T data) { + RBlockingQueue<T> queue = CLIENT.getBlockingQueue(queueName); + return queue.remove(data); + } + + /** + * 閫氱敤閿�姣侀槦鍒� 鎵�鏈夐樆濉炵洃鍚� 鎶ラ敊(涓嶆敮鎸佸欢杩熼槦鍒�) + */ + public static <T> boolean destroyQueue(String queueName) { + RBlockingQueue<T> queue = CLIENT.getBlockingQueue(queueName); + return queue.delete(); } /** @@ -85,32 +121,6 @@ } /** - * 灏濊瘯璁剧疆 浼樺厛闃熷垪姣旇緝鍣� 鐢ㄤ簬鎺掑簭浼樺厛绾� - * - * @param queueName 闃熷垪鍚� - * @param comparator 姣旇緝鍣� - */ - public static <T> boolean trySetPriorityQueueComparator(String queueName, Comparator<T> comparator) { - RPriorityBlockingQueue<T> priorityBlockingQueue = CLIENT.getPriorityBlockingQueue(queueName); - return priorityBlockingQueue.trySetComparator(comparator); - } - - /** - * 灏濊瘯璁剧疆 浼樺厛闃熷垪姣旇緝鍣� 鐢ㄤ簬鎺掑簭浼樺厛绾� - * - * @param queueName 闃熷垪鍚� - * @param comparator 姣旇緝鍣� - * @param destroy 宸插瓨鍦ㄦ槸鍚﹂攢姣� - */ - public static <T> boolean trySetPriorityQueueComparator(String queueName, Comparator<T> comparator, boolean destroy) { - RPriorityBlockingQueue<T> priorityBlockingQueue = CLIENT.getPriorityBlockingQueue(queueName); - if (priorityBlockingQueue.isExists() && destroy) { - destroyPriorityQueueObject(queueName); - } - return priorityBlockingQueue.trySetComparator(comparator); - } - - /** * 娣诲姞浼樺厛闃熷垪鏁版嵁 * * @param queueName 闃熷垪鍚� @@ -119,32 +129,6 @@ public static <T> boolean addPriorityQueueObject(String queueName, T data) { RPriorityBlockingQueue<T> priorityBlockingQueue = CLIENT.getPriorityBlockingQueue(queueName); return priorityBlockingQueue.offer(data); - } - - /** - * 鑾峰彇涓�涓紭鍏堥槦鍒楁暟鎹� 娌℃湁鏁版嵁杩斿洖 null - * - * @param queueName 闃熷垪鍚� - */ - public static <T> T getPriorityQueueObject(String queueName) { - RPriorityBlockingQueue<T> priorityBlockingQueue = CLIENT.getPriorityBlockingQueue(queueName); - return priorityBlockingQueue.poll(); - } - - /** - * 鍒犻櫎浼樺厛闃熷垪鏁版嵁 - */ - public static <T> boolean removePriorityQueueObject(String queueName, T data) { - RPriorityBlockingQueue<T> priorityBlockingQueue = CLIENT.getPriorityBlockingQueue(queueName); - return priorityBlockingQueue.remove(data); - } - - /** - * 閿�姣佷紭鍏堥槦鍒� - */ - public static boolean destroyPriorityQueueObject(String queueName) { - RPriorityBlockingQueue<?> priorityBlockingQueue = CLIENT.getPriorityBlockingQueue(queueName); - return priorityBlockingQueue.delete(); } /** @@ -168,7 +152,7 @@ public static <T> boolean trySetBoundedQueueCapacity(String queueName, int capacity, boolean destroy) { RBoundedBlockingQueue<T> boundedBlockingQueue = CLIENT.getBoundedBlockingQueue(queueName); if (boundedBlockingQueue.isExists() && destroy) { - destroyBoundedQueueObject(queueName); + destroyQueue(queueName); } return boundedBlockingQueue.trySetCapacity(capacity); } @@ -183,32 +167,6 @@ public static <T> boolean addBoundedQueueObject(String queueName, T data) { RBoundedBlockingQueue<T> boundedBlockingQueue = CLIENT.getBoundedBlockingQueue(queueName); return boundedBlockingQueue.offer(data); - } - - /** - * 鑾峰彇涓�涓湁鐣岄槦鍒楁暟鎹� 娌℃湁鏁版嵁杩斿洖 null - * - * @param queueName 闃熷垪鍚� - */ - public static <T> T getBoundedQueueObject(String queueName) { - RBoundedBlockingQueue<T> boundedBlockingQueue = CLIENT.getBoundedBlockingQueue(queueName); - return boundedBlockingQueue.poll(); - } - - /** - * 鍒犻櫎鏈夌晫闃熷垪鏁版嵁 - */ - public static <T> boolean removeBoundedQueueObject(String queueName, T data) { - RBoundedBlockingQueue<T> boundedBlockingQueue = CLIENT.getBoundedBlockingQueue(queueName); - return boundedBlockingQueue.remove(data); - } - - /** - * 閿�姣佹湁鐣岄槦鍒� - */ - public static boolean destroyBoundedQueueObject(String queueName) { - RBoundedBlockingQueue<?> boundedBlockingQueue = CLIENT.getBoundedBlockingQueue(queueName); - return boundedBlockingQueue.delete(); } /** -- Gitblit v1.9.3