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 复制代码

接收消息

属性配置

相关推荐
一个没有本领的人8 小时前
UIU-Net运行记录
python
国强_dev8 小时前
Python 的“非直接原因”报错
开发语言·python
YMatrix 官方技术社区8 小时前
YMatrix 存储引擎解密:MARS3 存储引擎如何超越传统行存、列存实现“时序+分析“场景性能大幅提升?
开发语言·数据库·时序数据库·数据库架构·智慧工厂·存储引擎·ymatrix
玖疯子8 小时前
技术文章大纲:Bug悬案侦破大会
开发语言·ar
副露のmagic8 小时前
更弱智的算法学习 day24
python·学习·算法
廖圣平8 小时前
从零开始,福袋直播间脚本研究【三】《多进程执行selenium》
python·selenium·测试工具
独自破碎E8 小时前
解释一下NIO、BIO、AIO
java·开发语言·nio
草莓熊Lotso8 小时前
脉脉独家【AI创作者xAMA】|当豆包手机遭遇“全网封杀”:AI学会操作手机,我们的饭碗还保得住吗?
运维·开发语言·人工智能·智能手机·脉脉
@areok@9 小时前
C++opencv图片(mat)传入C#bitmap图片
开发语言·c++·opencv
散峰而望9 小时前
【Coze - AI Agent 开发平台】-- 你真的了解 Coze 吗
开发语言·人工智能·python·aigc·ai编程·ai写作