RabbitMQ 工作队列

Java63

每日一句

如果你执意追逐我的幻影,迟早会被真正的我打败。

https://www.ylcoder.top/post/1649241412

概述

工作队列(也称为任务队列)的主要思想是避免立即执行资源密集型任务。我们可以在执行任务之前安排任务。

[En]

The main idea of work queue (also known as task queue) is to avoid executing resource intensive tasks immediately. We can arrange tasks before executing them.

我们将任务封装为消息并将其发送到队列。在后台运行的工作流程将弹出任务并最终执行作业。

[En]

We encapsulate the task as a message and send it to the queue. The work process running in the background will pop up the task and finally execute the job.

当有多个工作线程时,这些工作线程将一起处理这些任务。

轮询分发消息

在这里案例中我们会启动两个工作线程,一个消息发送线程

源码:https://github.com/yltrcc/rabbitmq-demo/tree/master/demo2/src/main/java/com/yltrcc/demo

输入验证码查看隐藏内容

扫描二维码关注本站微信公众号 Johngo学长
或者在微信里搜索 Johngo学长
回复 svip 获取验证码
wechat Johngo学长