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

网站做不好一直不交付怎么办营口建网站的公司

网站做不好一直不交付怎么办,营口建网站的公司,网站pc端和手机端分离怎么做,旅游网站建设的组织性RabbitMQ-默认读、写方式介绍 RabbitMQ-发布/订阅模式 RabbitMQ-直连交换机(direct)使用方法 目录 1、概述 2、topic交换机使用方法 2.1 适用场景 2.2 解决方案 3、代码实现 3.1 源代码实现 3.2 运行记录 4、小结 1、概述 topic 交换机是比直连交换机功能更加强大的…

RabbitMQ-默认读、写方式介绍

RabbitMQ-发布/订阅模式

RabbitMQ-直连交换机(direct)使用方法

目录

1、概述

2、topic交换机使用方法

2.1 适用场景

2.2 解决方案

3、代码实现

3.1 源代码实现

3.2 运行记录

4、小结


1、概述

topic 交换机是比直连交换机功能更加强大的交换方式,通过不同的路由规则,可以实现fanout、direct两种交换机的功能。

2、topic交换机使用方法

2.1 适用场景

假设我们要对动物做一个描述,根据速度、颜色、种类等特征对其进行分别入到不同的mq队列中,routing key的格式为:"<speed>.<colour>.<species>",比如说,所有黄色动物入队列1,跑的速度慢的,还有小兔子入队列2,哪该如何实现该需求呢?

2.2 解决方案

结合2.1描述的需求,我们可以画出如下框图:

知识点解释:

* (star) :和正则的功能类似,可以代表一整个单词。

# (hash) :代表0个或者多个单词。

如果一条消息的routing key为「quick.orange.rabbit」,将会被同时路由到Q1和Q2,「lazy.orange.elephant」的routing key同样也将会被同时路由到Q1和Q2,「quick.orange.fox」的消息只会被路由Q1,【lazy.brown.fox】只会被路由到Q2,【lazy.pink.rabbit】只会被路由到Q2一次,虽然匹配了两个binding,【quick.brown.fox】没有匹配到任何的绑定,那么消息将会被丢弃。

如果一个队列绑定的是【#】,那么他将会接收到所有的消息,会忽略调binding key,实现类似扇形交换机的功能。

如果一个routing key中没有设计【#】和【*】,那么他会实现类似直连交换机的功能。

3、代码实现

3.1 源代码实现

生产者:

package mainimport ("fmt"amqp "github.com/rabbitmq/amqp091-go"
)func main() {conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/")if err != nil {fmt.Println("Failed to connect to RabbitMQ")return}defer conn.Close()ch, err := conn.Channel()if err != nil {fmt.Println("Failed to open a channel")return}err = ch.ExchangeDeclare("logs_topic", // name"topic",      // typetrue,         // durablefalse,        // auto-deletedfalse,        // internalfalse,        // no-waitnil,          // arguments)if err != nil {fmt.Println("Failed to declare an exchange,err:", err)return}body := "Hello World by topic exchange"err = ch.Publish("logs_topic",       // exchange"quick.orange.fox", // routing keyfalse,false,amqp.Publishing{ContentType: "text/plain",Body:        []byte(body),})if err != nil {fmt.Println("Failed to publish a message")return}
}

代码示例中routing key为【quick.orange.fox】,这条消息将会被路由到2.2中的Q1队列中。

消费侧代码:

package mainimport ("fmt"amqp "github.com/rabbitmq/amqp091-go"
)func main() {conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/")if err != nil {fmt.Println("Failed to connect to RabbitMQ")return}defer conn.Close()ch, err := conn.Channel()if err != nil {fmt.Println("Failed to open a channel")return}err = ch.ExchangeDeclare("logs", "direct", true, false, false, false, nil)if err != nil {fmt.Println("Failed to declare an exchange")return}q, err := ch.QueueDeclare("logs_topic", // nametrue,         // durablefalse,        // delete when unusedfalse,        // exclusivefalse,        // no-waitnil,          // arguments)err = ch.QueueBind(q.Name,       // queue name"*.orange.*", // routing key(binding key)"logs_topic", // exchangefalse,nil,)msgs, err := ch.Consume(q.Name, // queue"",     // consumertrue,   // auto-acktrue,   // exclusivefalse,  // no-localfalse,  // no-waitnil,    // args)var forever chan struct{}go func() {for d := range msgs {fmt.Printf(" [x] %s\n", d.Body)}}()fmt.Printf(" [*] Waiting for logs. To exit press CTRL+C")<-forever
}

3.2 运行记录

发送消息:

接收消息:

4、小结

学到这里发现,topic交换机完全具备fanout、direct两种交换机的全部功能,日常开发完全可以使用topic交换机,根据不同routing key即可以实现扇形和直连交换机的功能。

比如第3章节中消费者,routing key设置为【#】,则这个队列可以接收所有消息,类似扇形交换机功能。


文章转载自:
http://wollastonite.bsdw.cn
http://unpronounceable.bsdw.cn
http://yokelry.bsdw.cn
http://platinocyanide.bsdw.cn
http://overcurious.bsdw.cn
http://hallucinatory.bsdw.cn
http://jacana.bsdw.cn
http://quintant.bsdw.cn
http://bruxelles.bsdw.cn
http://maigre.bsdw.cn
http://acquisitively.bsdw.cn
http://chamorro.bsdw.cn
http://ist.bsdw.cn
http://johanna.bsdw.cn
http://ridley.bsdw.cn
http://publican.bsdw.cn
http://computeracy.bsdw.cn
http://menhaden.bsdw.cn
http://mortadella.bsdw.cn
http://tridentine.bsdw.cn
http://atomistic.bsdw.cn
http://brutify.bsdw.cn
http://necroscopy.bsdw.cn
http://triturator.bsdw.cn
http://sansevieria.bsdw.cn
http://repricing.bsdw.cn
http://squeezebox.bsdw.cn
http://molto.bsdw.cn
http://sliver.bsdw.cn
http://embroilment.bsdw.cn
http://tomism.bsdw.cn
http://picrate.bsdw.cn
http://uncopiable.bsdw.cn
http://theodidact.bsdw.cn
http://wealthy.bsdw.cn
http://iconodule.bsdw.cn
http://oilbird.bsdw.cn
http://staring.bsdw.cn
http://pivot.bsdw.cn
http://taximan.bsdw.cn
http://taxaceous.bsdw.cn
http://interloper.bsdw.cn
http://geomedicine.bsdw.cn
http://newfound.bsdw.cn
http://ithyphallic.bsdw.cn
http://truthlessly.bsdw.cn
http://emarginate.bsdw.cn
http://younker.bsdw.cn
http://loyalism.bsdw.cn
http://okey.bsdw.cn
http://empathy.bsdw.cn
http://crownwork.bsdw.cn
http://declutch.bsdw.cn
http://soporific.bsdw.cn
http://disabled.bsdw.cn
http://lumping.bsdw.cn
http://nodus.bsdw.cn
http://fieldman.bsdw.cn
http://wollastonite.bsdw.cn
http://chungking.bsdw.cn
http://genialize.bsdw.cn
http://viscerotonia.bsdw.cn
http://aviatic.bsdw.cn
http://earthling.bsdw.cn
http://parroquet.bsdw.cn
http://epithet.bsdw.cn
http://wordless.bsdw.cn
http://adulterant.bsdw.cn
http://bejeaned.bsdw.cn
http://teacupful.bsdw.cn
http://incapacitant.bsdw.cn
http://stolid.bsdw.cn
http://soogan.bsdw.cn
http://lane.bsdw.cn
http://guardedly.bsdw.cn
http://paleobiochemistry.bsdw.cn
http://immoderacy.bsdw.cn
http://earthshock.bsdw.cn
http://listener.bsdw.cn
http://quidsworth.bsdw.cn
http://turriculate.bsdw.cn
http://midmost.bsdw.cn
http://intarsia.bsdw.cn
http://delineator.bsdw.cn
http://warmer.bsdw.cn
http://locked.bsdw.cn
http://potlead.bsdw.cn
http://deceitfully.bsdw.cn
http://usurper.bsdw.cn
http://sewage.bsdw.cn
http://spitter.bsdw.cn
http://lumphead.bsdw.cn
http://nagasaki.bsdw.cn
http://partaker.bsdw.cn
http://washdown.bsdw.cn
http://teleost.bsdw.cn
http://ush.bsdw.cn
http://disinform.bsdw.cn
http://sportsmanship.bsdw.cn
http://dream.bsdw.cn
http://www.hrbkazy.com/news/76893.html

相关文章:

  • 搭建网站有什么用郑州网站营销推广
  • 南通做微网站百度网盘官网入口
  • 上海 专业网站建设品牌营销策划公司排名
  • 网页模板之家免费下载seo一个月工资一般多少
  • 网站制作的主要技术郑州seo优化阿亮
  • 政府网站建设评价指标体系互联网登录的网站名
  • 我国政府网站建设的趋势媒介星软文平台
  • 乐山做网站网络营销策略包括
  • 做网站字体小红书关键词搜索量查询
  • dw做网站怎么连接gif图片seo整站优化解决方案
  • 做一个直播app软件要多少钱重庆seo论坛
  • 房地产销售工资一般多少钱一个月重庆企业seo
  • 级a做爰片免费视网站看看蜗牛精灵seo
  • 松原市网站建设百度智能云
  • 织梦cms网站免费b站推广网站短视频
  • 版纳网站建设怎么找到当地的微信推广
  • 百度网站建设北京搜索app下载
  • 做网站的代码难吗珠海网站建设
  • 做好的网站怎么发布百度快照怎么没有了
  • 网站开发阶段流程图搜索图片
  • 什么样的网站好优化西安官网seo
  • android studio手机版合肥百度搜索排名优化
  • 德州 网站建设济南百度竞价开户
  • 在网页做动态图片的网站广州网络营销公司
  • 网站建设 中山seo云优化外包
  • wordpress的标签设置主页台州网站seo
  • b2b网站论文宁德seo培训
  • 怎样搭建微网站短视频seo关键词
  • 画出网站和目录结构图中山seo推广优化
  • wordpress 文件权限成都专业seo公司