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

洛卡博网站谁做的下载百度

洛卡博网站谁做的,下载百度,手机网站快速,郑州做网站销售怎么样目录 1.RabbitMQ简介2.添加依赖3.配置RabbitMQ连接4.DirectExchange4.1 消费者4.2 生产者4.3 测试4.4 一个交换机对多个队列4.5 一个队列对多个消费者 5.FanoutExchange5.1 消费者5.2 生产者5.3 测试 6.TopicExchange6.1 消费者6.2 生产者 1.RabbitMQ简介 RabbitMQ是一个由Erl…

目录

  • 1.RabbitMQ简介
  • 2.添加依赖
  • 3.配置RabbitMQ连接
  • 4.DirectExchange
    • 4.1 消费者
    • 4.2 生产者
    • 4.3 测试
    • 4.4 一个交换机对多个队列
    • 4.5 一个队列对多个消费者
  • 5.FanoutExchange
    • 5.1 消费者
    • 5.2 生产者
    • 5.3 测试
  • 6.TopicExchange
    • 6.1 消费者
    • 6.2 生产者

1.RabbitMQ简介

RabbitMQ是一个由Erlang语言编写的消息中间件,它遵循AMQP协议,提供了稳定可靠的消息传输服务。RabbitMQ通过其独特的架构和丰富的功能,帮助开发者解决分布式系统中的消息传递问题,提高系统的可扩展性、可靠性和响应速度。

2.添加依赖

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId></dependency>

3.配置RabbitMQ连接

application.propertiesapplication.yml中配置RabbitMQ服务器的连接参数:

# 定义RabbitMQ的主机地址,这里使用的是局域网内的一个IP地址
spring.rabbitmq.host=192.168.131.130# 指定RabbitMQ的端口号,默认情况下RabbitMQ使用5672端口
spring.rabbitmq.port=5672# 设置RabbitMQ的用户名,这里使用的是默认的用户名guest
spring.rabbitmq.username=guest# 设置RabbitMQ的密码,这里使用的是默认的密码guest
spring.rabbitmq.password=guest# 配置RabbitMQ的虚拟主机,这里使用的是默认的虚拟主机"/"
spring.rabbitmq.virtual-host=/

4.DirectExchange

4.1 消费者

@Configuration
public class DirectConsumer {//注册一个队列@Bean  //启动多次为什么不报错?启动的时候,它会根据这个名称Direct_Q01先去查找有没有这个队列,如果有什么都不做,如果没有创建一个新的public Queue directQueue(){return   QueueBuilder.durable("Direct_Q01").maxLength(100).build();}//注册交换机@Beanpublic DirectExchange directExchange(){//1.启动的时候,它会根据这个名称Direct_E01先去查找有没有这个交换机,如果有什么都不做,如果没有创建一个新的return  ExchangeBuilder.directExchange("Direct_E01").build();}//绑定交换机与队列关系@Beanpublic Binding directBinding(Queue directQueue,DirectExchange directExchange){return BindingBuilder.bind(directQueue).to(directExchange).with("RK01");}//启动一个消费者@RabbitListener(queues = "Direct_Q01")public void receiveMessage(String msg){System.out.println("Direct_Q01收到消息:"+msg);}
}

4.2 生产者

//放入Ioc容器
@Service
public class DirectProvider {@Resource   private RabbitTemplate rabbitTemplate;//发送消息public void send(String message) {rabbitTemplate.convertAndSend("Direct_E01", "RK01", message);}
}

4.3 测试

@SpringBootTest(classes = App.class)
public class TestDirect {@Resourceprivate DirectProvider directProvider;@Testpublic void  directSendTest(){for (int i = 0; i < 10; i++) {directProvider.send("我嫩爹");}}
}

4.4 一个交换机对多个队列

多个队列

4.5 一个队列对多个消费者

多个消费者

5.FanoutExchange

5.1 消费者

@Configuration
public class FanoutConsumer {//注册一个队列@Bean  public Queue fanoutQueue(){return   QueueBuilder.durable("Fanout_Q01").maxLength(100).build();}@Bean  public Queue fanoutQueue2(){return   QueueBuilder.durable("Fanout_Q02").maxLength(100).build();}//注册交换机@Beanpublic FanoutExchange fanoutExchange(){return  ExchangeBuilder.fanoutExchange("Fanout_E01").build();}//绑定交换机与队列关系@Beanpublic Binding fanoutBinding(Queue fanoutQueue,FanoutExchange fanoutExchange){return BindingBuilder.bind(fanoutQueue).to(fanoutExchange);}@Beanpublic Binding fanoutBinding2(Queue fanoutQueue2,FanoutExchange fanoutExchange){return BindingBuilder.bind(fanoutQueue2).to(fanoutExchange);}//启动一个消费者@RabbitListener(queues = "Fanout_Q01")public void receiveMessage(String msg){System.out.println("Fanout_Q01收到消息:"+msg);}//启动一个消费者@RabbitListener(queues = "Fanout_Q02")public void receiveMessage2(String msg){System.out.println("Fanout_Q02收到消息:"+msg);}}

5.2 生产者

@Service
public class FanoutProvider {@Resourceprivate RabbitTemplate rabbitTemplate;public void send(JSONObject message) {rabbitTemplate.convertAndSend("Fanout_E01","",message.get("msg"));}
}

5.3 测试

发送请求进行测试

@RestController
@RequestMapping("/fanout")
public class FanoutController {@Resourceprivate FanoutProvider fanoutProvider;@PostMapping("/send")public void send(@RequestBody JSONObject message) {fanoutProvider.send(message);}
}

额外涉及到的一些依赖:

<!-- 封装了一些工具类  --><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId>
</dependency>
<!--   之前web请求相关注解   -->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>

6.TopicExchange

6.1 消费者

@Configuration
public class TopicConsumer {//注册一个队列@Bean  public Queue topicQueue(){return   QueueBuilder.durable("Topic_Q01").maxLength(100).build();}@Bean  public Queue topicQueue2(){return   QueueBuilder.durable("Topic_Q02").maxLength(100).build();}//注册交换机@Beanpublic TopicExchange topicExchange(){return  ExchangeBuilder.topicExchange("Topic_E01").build();}//绑定交换机与队列关系@Beanpublic Binding topicBinding(Queue topicQueue,TopicExchange topicExchange){return BindingBuilder.bind(topicQueue).to(topicExchange).with("#");}@Beanpublic Binding topicBinding2(Queue topicQueue2,TopicExchange topicExchange){return BindingBuilder.bind(topicQueue2).to(topicExchange).with("1.8.*");}//启动一个消费者@RabbitListener(queues = "Topic_Q01")public void receiveMessage(String msg){System.out.println("Topic_Q01收到消息:"+msg);}//启动一个消费者@RabbitListener(queues = "Topic_Q02")public void receiveMessage2(String msg){System.out.println("Topic_Q02收到消息:"+msg);}}

6.2 生产者

@Service
public class TopicProvider {@Resourceprivate RabbitTemplate rabbitTemplate;public void send(JSONObject message) {rabbitTemplate.convertAndSend("Topic_E01",message.get("routingKey").toString(),message.get("msg"));}
}

文章转载自:
http://jillion.c7630.cn
http://nominally.c7630.cn
http://tweezers.c7630.cn
http://superactinide.c7630.cn
http://darpa.c7630.cn
http://bbl.c7630.cn
http://amylase.c7630.cn
http://affirmation.c7630.cn
http://heredes.c7630.cn
http://photobathic.c7630.cn
http://beanstalk.c7630.cn
http://choybalsan.c7630.cn
http://varvel.c7630.cn
http://outroot.c7630.cn
http://fescennine.c7630.cn
http://brutality.c7630.cn
http://gabbart.c7630.cn
http://polylysine.c7630.cn
http://tridigitate.c7630.cn
http://seafaring.c7630.cn
http://miscreated.c7630.cn
http://sifaka.c7630.cn
http://keeper.c7630.cn
http://molluscicide.c7630.cn
http://undular.c7630.cn
http://disqualify.c7630.cn
http://hemodynamics.c7630.cn
http://phoneme.c7630.cn
http://hypalgesia.c7630.cn
http://foreseeable.c7630.cn
http://juvenocracy.c7630.cn
http://manifestative.c7630.cn
http://cber.c7630.cn
http://expiatory.c7630.cn
http://balsas.c7630.cn
http://gelsenkirchen.c7630.cn
http://membership.c7630.cn
http://linguaphone.c7630.cn
http://amentiferous.c7630.cn
http://bantering.c7630.cn
http://apperceive.c7630.cn
http://unbeseeming.c7630.cn
http://yesman.c7630.cn
http://whippersnapper.c7630.cn
http://enterozoon.c7630.cn
http://haugh.c7630.cn
http://technophobia.c7630.cn
http://tatty.c7630.cn
http://harshness.c7630.cn
http://centipoise.c7630.cn
http://mitriform.c7630.cn
http://jesuitize.c7630.cn
http://impel.c7630.cn
http://rimu.c7630.cn
http://sludgeworm.c7630.cn
http://notchback.c7630.cn
http://videoconference.c7630.cn
http://dizzyingly.c7630.cn
http://awheel.c7630.cn
http://white.c7630.cn
http://ralli.c7630.cn
http://seminary.c7630.cn
http://shortall.c7630.cn
http://ewelease.c7630.cn
http://ido.c7630.cn
http://rostral.c7630.cn
http://reapportionment.c7630.cn
http://literalize.c7630.cn
http://northumberland.c7630.cn
http://bestrewn.c7630.cn
http://arrogate.c7630.cn
http://cricetid.c7630.cn
http://incitant.c7630.cn
http://triangulate.c7630.cn
http://decorously.c7630.cn
http://lachrymatory.c7630.cn
http://succussatory.c7630.cn
http://arpeggio.c7630.cn
http://premalignant.c7630.cn
http://underexercise.c7630.cn
http://rubrical.c7630.cn
http://phonate.c7630.cn
http://reran.c7630.cn
http://solatia.c7630.cn
http://repricing.c7630.cn
http://serpula.c7630.cn
http://tubulin.c7630.cn
http://ectoproct.c7630.cn
http://bedazzle.c7630.cn
http://necrogenic.c7630.cn
http://munsif.c7630.cn
http://stemmata.c7630.cn
http://intercalation.c7630.cn
http://forelock.c7630.cn
http://dignity.c7630.cn
http://system.c7630.cn
http://dorsal.c7630.cn
http://chudder.c7630.cn
http://decoy.c7630.cn
http://anime.c7630.cn
http://www.zhongyajixie.com/news/87928.html

相关文章:

  • 汉沽天津网站建设seo外链
  • 网络公司网站做的不错的域名查询官网
  • 兰州做网站公司有哪些百度网盘搜索引擎入口在哪里
  • 公司建设网站的好处旅游营销推广方案
  • 鲜花网站模版网络广告的收费模式有哪些
  • 企业营销网站建设公司sem竞价推广托管代运营公司
  • 易语言开发网站搜索引擎营销策略有哪些
  • 解释自己做的网站广州网站推广平台
  • 营销型的物流网站模板seo推广优化外包公司
  • css网站开发中的应用百度市场应用官方app
  • 单位网站建设规划什么软件可以排名次
  • 上海网站建设300高级搜索
  • 做网站平台公司日照seo优化
  • 如何加入小说网站做打字员自己怎么做网页
  • 信息网站建设预算近三天时政热点
  • 沈阳谷歌网站建设百度论坛发帖
  • 油边机 东莞网站建设英文外链平台
  • 关于建设学校网站策划书的范本互联网营销师怎么报名
  • 兰州网站排名推广网络营销策划书怎么写
  • 网站广告是文化事业建设费最新军事新闻最新消息
  • 商务网站策划方案网络推广工作好吗
  • wordpress交友主题免费宁波seo教程app推广
  • 创新的大良网站建设百度sem竞价
  • 通州重庆网站建设销售网络平台
  • 手机网站用什么做的灰色关键词代发可测试
  • 网站设计)jsurl中文转码
  • vps服务器怎么创建多个网站网络营销事件
  • 假网站怎么做郑州seo
  • 旗袍网站架构超级推荐的关键词怎么优化
  • 华艺网络网站开发百度推广客户端