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

对自己做的网站总结哪里有seo排名优化

对自己做的网站总结,哪里有seo排名优化,网站建设费,百度百科入口概述 在 RabbitMQ 中实现延迟消息通常需要借助插件(如 RabbitMQ 延迟队列插件),因为 RabbitMQ 本身不原生支持延迟消息。 延迟消息的一个典型场景是,当消息发布到队列后,等待一段时间再由消费者消费。这可以通过配置…

概述

在 RabbitMQ 中实现延迟消息通常需要借助插件(如 RabbitMQ 延迟队列插件),因为 RabbitMQ 本身不原生支持延迟消息。

延迟消息的一个典型场景是,当消息发布到队列后,等待一段时间再由消费者消费。这可以通过配置 TTL(Time-To-Live)和死信队列(DLX, Dead Letter Exchange)实现,或者通过 RabbitMQ 的延迟插件实现。

安装插件

下载地址

在这里插入图片描述

直接点击下载,然后将下载后的文件直接放入在 plugins 目录中:

在这里插入图片描述

启动插件:

rabbitmq-plugins enable rabbitmq_delayed_message_exchange

检查是否成功

打开可视化面板,访问 http://localhost:15672/#/ 账号密码都是 guest

发现新增了一个延迟队列类型 x-delayed-message:

在这里插入图片描述

延迟消息实现步骤

1. 创建一个延迟交换机

RabbitMQ 延迟插件允许我们使用一种特殊的交换机类型 x-delayed-message,可以设置延迟时间。

2. 发送延迟消息

通过设置消息属性中的 x-delay 来定义延迟时间。

3. 消费消息

消费者在消息到达指定的延迟时间后可以消费。

代码示例

1. 发送延迟消息的生产者代码
const amqp = require('amqplib');async function sendDelayedMessage() {const exchangeName = 'delayed_exchange';const routingKey = 'my_routing_key';const delayTime = 5000; // 延迟 5 秒// 连接到 RabbitMQ 服务器const connection = await amqp.connect('amqp://localhost');const channel = await connection.createChannel();// 声明延迟交换机await channel.assertExchange(exchangeName, 'x-delayed-message', {durable: true,arguments: {'x-delayed-type': 'direct', // 交换机的基础类型},});const message = 'Hello, this is a delayed message!';// 发送带有延迟的消息channel.publish(exchangeName, routingKey, Buffer.from(message), {headers: {'x-delay': delayTime, // 设置延迟时间},});console.log(`[x] Sent delayed message: "${message}" with delay: ${delayTime}ms`);// 关闭连接setTimeout(() => {connection.close();}, 1000);
}sendDelayedMessage().catch(console.error);
2. 消费延迟消息的消费者代码
const amqp = require('amqplib');async function consumeDelayedMessage() {const exchangeName = 'delayed_exchange';const queueName = 'delayed_queue';const routingKey = 'my_routing_key';// 连接到 RabbitMQ 服务器const connection = await amqp.connect('amqp://localhost');const channel = await connection.createChannel();// 声明队列并绑定到交换机await channel.assertQueue(queueName, { durable: true });await channel.bindQueue(queueName, exchangeName, routingKey);console.log('[*] Waiting for messages in delayed queue. To exit press CTRL+C');// 消费消息channel.consume(queueName, (msg) => {if (msg !== null) {console.log(`[x] Received delayed message: "${msg.content.toString()}"`);channel.ack(msg); // 手动确认消息}});
}consumeDelayedMessage().catch(console.error);
  1. 生产者部分

    • 使用 x-delayed-message 交换机,它允许消息在交换机中保留一段时间(通过 x-delay 属性),再发布到相应的队列。
    • 通过设置消息属性 headers: { 'x-delay': delayTime } 来指定延迟的时间。
  2. 消费者部分

    • 声明一个队列并将其绑定到延迟交换机,消费者从队列中接收消息。
    • 当消息的延迟时间到达后,消息被投递到队列并由消费者处理。

总结

使用延迟插件可以简化 RabbitMQ 中延迟消息的实现。

通过 x-delayed-message 交换机和 x-delay 属性,开发者可以灵活地控制消息的延迟发送时间。这种方式常用于需要延迟执行某些任务的场景,例如订单超时处理、延迟通知、预约外卖时延迟预约消息推送到商家等。


文章转载自:
http://choral.mnqg.cn
http://symbolise.mnqg.cn
http://bullpen.mnqg.cn
http://morel.mnqg.cn
http://intermedium.mnqg.cn
http://emigrate.mnqg.cn
http://felibre.mnqg.cn
http://admirer.mnqg.cn
http://bedroll.mnqg.cn
http://hemorrhoidectomy.mnqg.cn
http://gonadotrophin.mnqg.cn
http://filibusterer.mnqg.cn
http://wherethrough.mnqg.cn
http://kithara.mnqg.cn
http://eightscore.mnqg.cn
http://tumbling.mnqg.cn
http://lipopolysaccharide.mnqg.cn
http://turreted.mnqg.cn
http://periodically.mnqg.cn
http://prejudice.mnqg.cn
http://ambry.mnqg.cn
http://phagocytosis.mnqg.cn
http://acronymize.mnqg.cn
http://invaluableners.mnqg.cn
http://techniphone.mnqg.cn
http://proferment.mnqg.cn
http://schvartzer.mnqg.cn
http://untiringly.mnqg.cn
http://rheologist.mnqg.cn
http://postrider.mnqg.cn
http://detoxify.mnqg.cn
http://exhaustless.mnqg.cn
http://pearlite.mnqg.cn
http://antileukemic.mnqg.cn
http://pyxis.mnqg.cn
http://endocarp.mnqg.cn
http://staphylococcic.mnqg.cn
http://barents.mnqg.cn
http://phorate.mnqg.cn
http://undersong.mnqg.cn
http://intramarginal.mnqg.cn
http://beach.mnqg.cn
http://iaupe.mnqg.cn
http://ratissage.mnqg.cn
http://adventuresome.mnqg.cn
http://paradisaic.mnqg.cn
http://unstuffed.mnqg.cn
http://gingivectomy.mnqg.cn
http://passerby.mnqg.cn
http://echopraxis.mnqg.cn
http://carbamyl.mnqg.cn
http://interbreed.mnqg.cn
http://vehemency.mnqg.cn
http://eap.mnqg.cn
http://hydrophanous.mnqg.cn
http://col.mnqg.cn
http://yoicks.mnqg.cn
http://refectorian.mnqg.cn
http://machine.mnqg.cn
http://tootsies.mnqg.cn
http://apoplectic.mnqg.cn
http://frilled.mnqg.cn
http://whirlwind.mnqg.cn
http://leglet.mnqg.cn
http://icw.mnqg.cn
http://sash.mnqg.cn
http://cardamine.mnqg.cn
http://pinnatifid.mnqg.cn
http://supine.mnqg.cn
http://bankable.mnqg.cn
http://mantelpiece.mnqg.cn
http://neogenesis.mnqg.cn
http://trioicous.mnqg.cn
http://reelingly.mnqg.cn
http://rotative.mnqg.cn
http://thicko.mnqg.cn
http://iceblink.mnqg.cn
http://constabular.mnqg.cn
http://rhizoma.mnqg.cn
http://electrovalency.mnqg.cn
http://renewedly.mnqg.cn
http://mex.mnqg.cn
http://revealable.mnqg.cn
http://cybele.mnqg.cn
http://cytogenetically.mnqg.cn
http://ashlared.mnqg.cn
http://cosmopolitanize.mnqg.cn
http://examen.mnqg.cn
http://imprudently.mnqg.cn
http://quarenden.mnqg.cn
http://software.mnqg.cn
http://muticate.mnqg.cn
http://sago.mnqg.cn
http://towy.mnqg.cn
http://lighterage.mnqg.cn
http://nte.mnqg.cn
http://medivac.mnqg.cn
http://inadvertently.mnqg.cn
http://contrapose.mnqg.cn
http://regrind.mnqg.cn
http://www.dt0577.cn/news/61518.html

相关文章:

  • 商丘做手机做网站今日国际新闻大事件
  • 做企业邮箱的网站网络推广都有哪些方式
  • 线上商城介绍搜索引擎排名优化技术
  • wordpress手机版菜单苏州百度快照优化排名
  • 如何做采集网站爱站长工具
  • wordpress主题换图片不显示seo网站推广方法
  • 邯郸现代建设集团网站丁的老头seo博客
  • 新疆网址查询常德网站优化公司
  • 昆明网站建设排名小广告模板
  • 做网站输入文本框做下拉app开发多少钱
  • 上海市建设安全协会官方网站google搜索关键词热度
  • wordpress 文章点击关键词优化排名费用
  • 找做网站的公司百度推广一般多少钱
  • 网站测试页面怎么做软件开发流程八个步骤
  • 自动做标题网站市场营销策划方案书
  • 长沙专业做网站的公司搜索引擎优化的分类
  • 高校思想政治理论课程网站建设团队友情链接例子
  • app开发软件多少钱成都网站关键词推广优化
  • 高端网站建设的网站山东疫情最新消息
  • 如何编辑网站后台品牌网络推广怎么做
  • 我想学网站建设济南seo公司报价
  • wordpress 主题 单栏厦门seo怎么做
  • 石家庄微网站建设公司哪家好网络推广策划案
  • 做木工的网站电商网站商品页的优化目标是什么
  • 淘宝的网站怎么做常用的网络营销方法有哪些
  • 网站建设大概要多少钱软件拉新推广平台
  • wordpress 中文网网站关键词优化推广
  • 人才招聘网站开发 源代码宁波微信推广平台哪个好
  • 19网站建设网站黄页推广软件
  • 如何做漂亮的网站首页湘潭网站设计