rqueue使用笔记

文章目录

项目用到rqueue,虽然知道和redis相关,但是肯定有不一样的地方,做个笔记。

maven依赖

网上找个能用的版本就行,如:

xml 复制代码
<dependency>
  <groupId>com.github.sonus21</groupId>
  <artifactId>rqueue-spring-boot-starter</artifactId>
  <version>2.13.2-RELEASE</version>
</dependency>

引入监听器

属于配置类,可以考虑和StartupApplication同目录。

java 复制代码
@Component
public class MessageSender implements ApplicationListener<RqueueBootstrapEvent> {
    @Autowired
    private RqueueEndpointManager rqueueEndpointManager;

    @Override
    public void onApplicationEvent(RqueueBootstrapEvent event) {
        if (!event.isStartup()) {
            return;
        }

        String[] a = new String[]{"ARCHIVES-CHECK-QUEUE","ARCHIVES-CONVERSION-QUEUE"};
        for (String queue : a) {
            String[] priorities = getPriority(queue);
            if (!rqueueEndpointManager.isQueueRegistered(queue)) {
                rqueueEndpointManager.registerQueue(queue, priorities);
            }
        }
    }

    private String[] getPriority(String queue) {
//        return new String[]{"high", "medium", "low"};
        return new String[]{};
    }
}

注入和发送消息

java 复制代码

接收消息

属性配置

相关推荐
nightunderblackcat19 分钟前
进阶向:人物关系三元组,解锁人物关系网络的钥匙
开发语言·python·开源·php
universe_0132 分钟前
day25|学习前端js
前端·笔记
站大爷IP35 分钟前
Pandas与NumPy:Python数据处理的双剑合璧
python
站大爷IP1 小时前
Python枚举进化论:IntEnum与StrEnum的实战指南
python
甄超锋1 小时前
python sqlite3模块
jvm·数据库·python·测试工具·django·sqlite·flask
科大饭桶1 小时前
C++入门自学Day11-- String, Vector, List 复习
c语言·开发语言·数据结构·c++·容器
teeeeeeemo1 小时前
如何做HTTP优化
前端·网络·笔记·网络协议·http
范范之交2 小时前
JavaScript基础语法two
开发语言·前端·javascript
Felven2 小时前
C. Game of Mathletes
c语言·开发语言
点云SLAM2 小时前
C++中内存池(Memory Pool)详解和完整示例
开发语言·c++·内存管理·内存池·new/delete·malloc/free