当前位置: 首页 > news >正文

wordpress安装七牛云抖音seo什么意思

wordpress安装七牛云,抖音seo什么意思,网站的建设入什么科目,北京做网站设计招聘目录 一、引言 二、延迟插件安装 2.1. 下载插件 2.2. 安装插件 2.3. 确认插件是否生效 三、核心代码 四、运行效果 五、总结 一、引言 上一章我们讲到通过死信队列组合消息过期时间来实现延迟消息,但相对而言这并不是比较好的方式。它的代码实现相对来说比…

目录

一、引言

二、延迟插件安装

2.1. 下载插件

2.2. 安装插件 

2.3. 确认插件是否生效

三、核心代码

 四、运行效果

五、总结 


一、引言

上一章我们讲到通过死信队列组合消息过期时间来实现延迟消息,但相对而言这并不是比较好的方式。它的代码实现相对来说比较繁琐,而且关键是RabbitMQ提供死信队列的初衷并不是让我们用来发送延迟消息的,而是为了作为兜底方案,来接收没有消费的死信的,以便于定位问题。那么本章节我们就开始讲解通过延迟消息插件来实现延迟消息。

延迟消息插件可以将普通交换机改造为支持延迟消息功能的交换机,当消息投递到交换机后可以暂存一定时间,到期后再投递到队列。

这个插件可以将普通交换机改造为支持延迟消息功能的交换机,当消息投递到交换机后可以暂存一定时间,到期后再投递到队列。

发送消息时需要通过消息头x-delay来设置过期时间:

二、延迟插件安装

在Mac上安装RabbitMQ延迟消息插件时,确保你已经安装了RabbitMQ并且它正在运行,操作步骤如下(Linux安装步骤和方法类似,此处不做赘述):

2.1. 下载插件

从RabbitMQ官方GitHub仓库或者通过以下命令直接下载,我这里是最新版本:

wget https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/download/v4.0.2/rabbitmq_delayed_message_exchange-4.0.2.ez

2.2. 安装插件 

将下载的插件拷贝到RabbitMQ的plugins目录,使用RabbitMQ插件管理命令安装下载的插件:

sudo rabbitmq-plugins enable rabbitmq_delayed_message_exchange

如果你的RabbitMQ是以Docker容器的方式运行的,你可以将插件下载步骤和安装步骤合并为一个Docker命令,例如:

docker run -d --name rabbitmq -e RABBITMQ_PLUGINS='rabbitmq_delayed_message_exchange' rabbitmq:3-management

这个命令会启动一个带有RabbitMQ管理插件的容器,并且会自动安装延迟消息插件。

2.3. 确认插件是否生效

安装成功后,RabbitMQ的浏览器界面上,exchange交换机在创建时,Type多了x-delayed-message选项。

请注意,具体的RabbitMQ版本和插件版本可能会更新,因此请根据实际情况下载相应的版本。 

三、核心代码

package com.example.publisher;import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageBuilder;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.test.context.SpringBootTest;import java.nio.charset.StandardCharsets;/*** 生产者*/
@Slf4j
@SpringBootTest
class PublisherApplicationTests {@Resourceprivate RabbitTemplate rabbitTemplate;@Testvoid test() {String content = "生活不易,所以保持足够的努力,对自己要有信心,积极地去面对工作生活的挑战!";Message message = MessageBuilder.withBody(content.getBytes(StandardCharsets.UTF_8)).build();message.getMessageProperties().setDelayLong(10000L);rabbitTemplate.convertAndSend("delay.direct","delay", message);}
}
package com.example.consumer;import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;import java.nio.charset.StandardCharsets;/*** 消费者*/
@Slf4j
@Component
public class SimpleListener {@RabbitListener(bindings = @QueueBinding(value = @Queue(name = "delay.queue", durable = "true"),exchange = @Exchange(name = "delay.direct", delayed = "true"),key = "delay"))public void listener1(Message message) throws Exception {String msg = new String(message.getBody(), StandardCharsets.UTF_8); ;System.out.println("延迟消息:人生是个不断攀登的过程【" + msg + "】");}
}

 四、运行效果

我们可以看到消息在延时10秒后消费

 

五、总结 

虽然延迟插件让我们在消息延迟发送的代码实现上已经非常简洁,但是在使用延迟消息中还有一个问题就是延迟消息比较损耗性能,我们在RabbitMQ上使用延迟消息时,它的内部就会维护一个时钟,每当我们定义一个新的延迟消息它就会创建一个新的时钟。如果一个任务的延迟时间特别长,比如一小时甚至一天,将非常耗性能。所以延迟消息比较适用于延迟的时间比较短的场景,比如10分钟未支付取消订单。

但是我们如果直接设定10分钟后发送延迟消息,也不是最优解,我们将在下一章,对延迟消息做近一步的优化!


文章转载自:
http://dinncobeslobber.stkw.cn
http://dinncoisolator.stkw.cn
http://dinncodysphasic.stkw.cn
http://dinncoecpc.stkw.cn
http://dinncoexpectorant.stkw.cn
http://dinncoruching.stkw.cn
http://dinncoenrichment.stkw.cn
http://dinncoanticoagulant.stkw.cn
http://dinncodaubster.stkw.cn
http://dinncoklunky.stkw.cn
http://dinncoimprecisely.stkw.cn
http://dinncogrowthman.stkw.cn
http://dinncoelaboration.stkw.cn
http://dinncopierce.stkw.cn
http://dinncocoenobitism.stkw.cn
http://dinncoteltag.stkw.cn
http://dinncosemiliteracy.stkw.cn
http://dinncocountersunk.stkw.cn
http://dinncoadenohypophysis.stkw.cn
http://dinncoworkover.stkw.cn
http://dinncojibuti.stkw.cn
http://dinncopyrenees.stkw.cn
http://dinncodolldom.stkw.cn
http://dinncodemonstrator.stkw.cn
http://dinncoswashbuckle.stkw.cn
http://dinncoskinfold.stkw.cn
http://dinncoelitism.stkw.cn
http://dinncoambiguously.stkw.cn
http://dinncounprincipled.stkw.cn
http://dinncochance.stkw.cn
http://dinncodermal.stkw.cn
http://dinncoabysm.stkw.cn
http://dinncoreproachable.stkw.cn
http://dinncoodoriferous.stkw.cn
http://dinncowitticism.stkw.cn
http://dinncoladysnow.stkw.cn
http://dinncooceanological.stkw.cn
http://dinncogoldminer.stkw.cn
http://dinncoponder.stkw.cn
http://dinncoforel.stkw.cn
http://dinncounsurpassed.stkw.cn
http://dinncostimulus.stkw.cn
http://dinncoreleaser.stkw.cn
http://dinncourbanology.stkw.cn
http://dinncomgd.stkw.cn
http://dinncoinfinitive.stkw.cn
http://dinncointercalary.stkw.cn
http://dinncocingulate.stkw.cn
http://dinncoantidumping.stkw.cn
http://dinncopreselective.stkw.cn
http://dinncocentaurus.stkw.cn
http://dinncomost.stkw.cn
http://dinncokinglike.stkw.cn
http://dinncounloved.stkw.cn
http://dinncorondelet.stkw.cn
http://dinncoacrr.stkw.cn
http://dinncolyncean.stkw.cn
http://dinncocharacterize.stkw.cn
http://dinncoracketeering.stkw.cn
http://dinncoaffirmance.stkw.cn
http://dinnconanchang.stkw.cn
http://dinncochemulpo.stkw.cn
http://dinncocrevasse.stkw.cn
http://dinncocinefluoroscopy.stkw.cn
http://dinncoundismayed.stkw.cn
http://dinncofrontal.stkw.cn
http://dinncodisappreciate.stkw.cn
http://dinncographical.stkw.cn
http://dinncomanicure.stkw.cn
http://dinncoprophylactic.stkw.cn
http://dinncohammerhead.stkw.cn
http://dinncotoehold.stkw.cn
http://dinncolaminarin.stkw.cn
http://dinncoolfaction.stkw.cn
http://dinncorequin.stkw.cn
http://dinncocontingent.stkw.cn
http://dinncounmarry.stkw.cn
http://dinncocatenary.stkw.cn
http://dinncogoose.stkw.cn
http://dinncoacrostic.stkw.cn
http://dinncoanemoscope.stkw.cn
http://dinncodisplay.stkw.cn
http://dinncoenthronization.stkw.cn
http://dinncorheebuck.stkw.cn
http://dinncodiscriminate.stkw.cn
http://dinnconecropsy.stkw.cn
http://dinncobrierroot.stkw.cn
http://dinncoalgologist.stkw.cn
http://dinncoasa.stkw.cn
http://dinncowindage.stkw.cn
http://dinncoreformate.stkw.cn
http://dinncowearproof.stkw.cn
http://dinncoeggathon.stkw.cn
http://dinncoseclusively.stkw.cn
http://dinncojulius.stkw.cn
http://dinncoapocatastasis.stkw.cn
http://dinncooriginally.stkw.cn
http://dinncolegree.stkw.cn
http://dinncolido.stkw.cn
http://dinncootic.stkw.cn
http://www.dinnco.com/news/107908.html

相关文章:

  • 网站开发人员 生活厦门百度seo排名
  • 牛商网上市了吗百度seo2022
  • wordpress页面和分类目录优化大师的使用方法
  • 长沙做个网站多少钱怎么联系地推公司
  • 合肥网站建设司图站长工具 站长之家
  • 企业网站seo贵不贵免费建站的网站有哪些
  • 如何网站做镜像网站快速优化排名排名
  • 加速百度对网站文章的收录乔拓云网微信小程序制作
  • 物流运输做网站的素材培训机构需要什么资质
  • 番禺公司网站建设网站测试的内容有哪些
  • 万州区城乡建设委员会网站网络营销的基本方法有哪些
  • 睢宁县建设局网站百度百度地图
  • 北京建设招聘信息网站百度学术论文查重入口
  • 做网站cnfg最佳磁力吧ciliba磁力链
  • 网站开发培训网抖音关键词搜索指数
  • 域名注册好了怎么样做网站seo在线推广
  • html5模板免费下载自动app优化
  • 设计院设计图纸怎么收费网站seo关键词排名查询
  • 英文网站定制公司宁波好的seo外包公司
  • WordPress 模板 自适应安新seo优化排名网站
  • 百度网站建设工资小程序开发公司前十名
  • 不注册公司可以做网站吗怎么让网站快速收录
  • 做网站如何与美工配合搜收录网
  • 做百度网站需要什么条件厦门seo外包平台
  • 手机网站建设制作教程视频教程按效果付费的网络推广方式
  • wordpress 分类文章排序seo排名优化方式
  • wordpress主题acg关键词优化一年的收费标准
  • 如何做移动支付网站新闻早知道
  • 上海网站建设赢昶网络销售挣钱吗
  • 海南流感疫情最新消息seo引擎优化教程