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

怎么将网站做成html帮助设计的网站

怎么将网站做成html,帮助设计的网站,制作网站的成本规划,市城乡规划建设局网站这目录 一、添加依赖二、配置文件中添加RabbitMQ访问配置三、消息生产者代码四、消息消费者代码五、验证参考资料 一、添加依赖 <!--AMQP依赖&#xff0c;包含RabbitMQ--><dependency><groupId>org.springframework.boot</groupId><artifactId>s…

这目录

  • 一、添加依赖
  • 二、配置文件中添加RabbitMQ访问配置
  • 三、消息生产者代码
  • 四、消息消费者代码
  • 五、验证
  • 参考资料

一、添加依赖

        <!--AMQP依赖,包含RabbitMQ--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId></dependency><!-- 引入knife4j-spring-ui包 /doc.html--><dependency><groupId>com.github.xiaoymin</groupId><artifactId>knife4j-spring-boot-starter</artifactId><version>3.0.3</version></dependency>

二、配置文件中添加RabbitMQ访问配置

spring.rabbitmq.host=192.168.0.104
spring.rabbitmq.port=5672
spring.rabbitmq.virtual-host=/
spring.rabbitmq.username=admin
spring.rabbitmq.password=admin123

三、消息生产者代码

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;@Api(tags = "生产者服务")
@RestController
public class ProducerController {@Autowiredprivate RabbitTemplate rabbitTemplate;@ApiOperation(value = "基本消息模型")@PostMapping("/testHello")public String testHello() {rabbitTemplate.convertAndSend("hello","hello world");return "ok";}@ApiOperation(value = "work消息模型")@PostMapping("/testWork")public String testWork() {for (int i = 0; i < 10; i++) {rabbitTemplate.convertAndSend("work","hello work!");}return "ok";}@ApiOperation(value = "订阅模型-Fanout 广播模式")@PostMapping("/testFanout")public String testFanout() {rabbitTemplate.convertAndSend("logs","","这是日志广播");return "ok";}@ApiOperation(value = "订阅模型-Direct")@PostMapping("/testDirect")public String testDirect() {rabbitTemplate.convertAndSend("directs","error","error 的日志信息");return "ok";}@ApiOperation(value = "订阅模型-Topic")@PostMapping("/testTopic")public String testTopic() {rabbitTemplate.convertAndSend("topics","user.save.findAll","user.save.findAll 的消息");return "ok";}
}

四、消息消费者代码

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;@Component
public class SpringRabbitListener {//基本消息模型@RabbitListener(queuesToDeclare = @Queue("hello"))public void receive(String message) {System.out.println("message = " + message);}//work消息模型@RabbitListener(queuesToDeclare = @Queue("work"))public void workReceive1(String message) {System.out.println("workReceive1 message = " + message);}//work消息模型@RabbitListener(queuesToDeclare = @Queue("work"))public void workReceive2(String message) {System.out.println("workReceive2 message = " + message);}//订阅模型-Fanout 广播模式@RabbitListener(bindings = @QueueBinding(value = @Queue, exchange = @Exchange(name="logs",type = "fanout")))public void fanoutReceive(String message) {System.out.println("fanoutReceive message = " + message);}//订阅模型-Direct@RabbitListener(bindings ={@QueueBinding(value = @Queue(),key={"info","error"},exchange = @Exchange(type = "direct",name="directs"))})public void directReceive(String message) {System.out.println("directReceive message = " + message);}//订阅模型-Topic@RabbitListener(bindings = {@QueueBinding( value = @Queue,key = {"user.*"},exchange = @Exchange(type = "topic",name = "topics"))})public void topicReceive1(String message) {System.out.println("topicReceive1 message = " + message);}//订阅模型-Topic@RabbitListener(bindings = {@QueueBinding(value = @Queue,key = {"user.#"},exchange = @Exchange(type = "topic",name = "topics"))})public void topicReceive2(String message) {System.out.println("topicReceive2 message = " + message);}}

五、验证

浏览器输入:ip:8080/doc.html 对接口逐个进行测试

参考资料

  1. RabbitMQ详解
  2. RabbitMQ五种消息模型
http://www.yayakq.cn/news/970034/

相关文章:

  • 如何看网站几级域名吴江企业网站建设
  • 多语言外贸网站开发百度关键词排名原理
  • 成都双流 网站建设wordpress安装无法链接数据库文件
  • 青海住房和城乡建设部网站江门做网站的公司
  • 嘉定网站制作找专业做网站的公司
  • 网站加速器免费网页截图快捷键ctrl
  • h5 app开发 网站建设wordpress怎么被百度收录
  • 买了虚拟主机怎么建设网站大连小程序制作开发
  • 深圳网站设计兴田德润官方网站教育机构网站建设
  • 付费资源下载站源码东莞网络营销班
  • 自己做视频网站可以吗怎么做网站推广佳木斯
  • 网站频道与栏目的区别如何设置网站公司动态
  • 兰州网站建设人才招聘怎么写代码做网站
  • 制作企业网站教程wordpress 收费阅读
  • 网站研发费用吗重庆市招标网官网
  • 建立企业网站价格泉州seo排名公司
  • 网站怎么建立小红书怎么推广自己的产品
  • 黄山地区建设行业网站亚马逊网站首页
  • kuake自助建站系统官网指数函数图像及性质
  • 自己的网站是什么样子的网站模板用什么打开
  • 深圳福田住房和建设局网站如何在网上开店
  • 网站icp不备案有关系吗桂林官网
  • 宁波住房和城乡建设网站wordpress themepath
  • 建网站自己与租云服务器哪个好wordpress 框架选择
  • 网站建设怎么报价表教育类网站建设方案
  • 网站建设企业所得税大宗商品交易app
  • 网站制作文章seo优化公司
  • 网站建设 熊掌号家居设计
  • 网站 空间德州鲁企动力网站优化中心
  • 南通网站建设推广优化湛江企业网站建设流程