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

哪些网站是wordpress互联网站账户e服务平台

哪些网站是wordpress,互联网站账户e服务平台,江西住房和城乡建设厅网站,百度网页链接这目录 一、添加依赖二、配置文件中添加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/711375/

相关文章:

  • 怎么套模板 网站模板网站内容建设和管理系统
  • 网页设计与网站建设考试名词解释2019上海官网建设教程
  • 管理系统网站开发wordpress流量插件
  • 网站建设支付安全如何建设国外的网站
  • 常州知名做网站服务温州最好的网站建设公司
  • 网站怎么弄实名制认证北京ui网页设计素材
  • 做网站域名费向哪里交做网站用什么字体最明显
  • 网站建设捌金手指花总二九网络推广网站公司
  • 做网站的学什么代码网站建设服务亿企网络
  • 重庆建设安全员信息网站在线设计房屋平面图
  • 定制制作网站价格表本地app制作公司电话
  • 手机网站建设是什么wordpress 打商插件
  • 网站排名提升工具广州品牌策划公司排行
  • 南开网站建设优化seo泰安百度推广代理
  • 注册个体工商户用于网站建设做一个软件需要哪些技术
  • 温州网站建设定制阿里云模板建站怎么样
  • 专门做辅助的扎金花网站如果网站不备案
  • 衡阳市建设学校官方网站牛博网站建设
  • 最好的锦州网站建设深圳龙华大浪做网站公司
  • 互联网大赛建设网站策划书如何将数据写入wordpress文站
  • 小组做数据库网站深圳营业执照网上申报入口
  • 下载app 的网站 如何做品牌建设的过程
  • 智能建站系统官网wordpress 技术网模板
  • 湖北专业网站建设网站建设的布局
  • 优秀企业网站模板下载网络模块
  • 长沙网站建设 个人为什么做电子商务网站的原因
  • 福田蒙派克7座商务车报价开鲁网站seo不用下载
  • wordpress网站建设教程惠州网站建设服务
  • 计算机应用技术网站开发介绍信誉好的品牌网站建设
  • PHP+MySQL网站开发全程实例王烨名字打分