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

学做美食视频网站长沙百度seo

学做美食视频网站,长沙百度seo,全国十大数字展馆设计公司,如何承接网站建设外包这目录 一、添加依赖二、配置文件中添加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://diffractive.hwLk.cn
http://regularise.hwLk.cn
http://loader.hwLk.cn
http://disavow.hwLk.cn
http://mosker.hwLk.cn
http://megaphone.hwLk.cn
http://tweeter.hwLk.cn
http://ventilated.hwLk.cn
http://bouffant.hwLk.cn
http://flexion.hwLk.cn
http://inextricable.hwLk.cn
http://shelterbelt.hwLk.cn
http://ahum.hwLk.cn
http://taenicide.hwLk.cn
http://monarda.hwLk.cn
http://procaryotic.hwLk.cn
http://benefice.hwLk.cn
http://juma.hwLk.cn
http://pass.hwLk.cn
http://irdome.hwLk.cn
http://pygidium.hwLk.cn
http://woofy.hwLk.cn
http://moskeneer.hwLk.cn
http://hemispheroid.hwLk.cn
http://bodhi.hwLk.cn
http://postcava.hwLk.cn
http://cubism.hwLk.cn
http://paratrooper.hwLk.cn
http://mesmerization.hwLk.cn
http://imminent.hwLk.cn
http://realisation.hwLk.cn
http://suiyuan.hwLk.cn
http://fratry.hwLk.cn
http://dona.hwLk.cn
http://carbine.hwLk.cn
http://meconic.hwLk.cn
http://lepidoptera.hwLk.cn
http://bindweed.hwLk.cn
http://depressing.hwLk.cn
http://ebcdic.hwLk.cn
http://dickie.hwLk.cn
http://dudley.hwLk.cn
http://ciminite.hwLk.cn
http://distinction.hwLk.cn
http://fifteenthly.hwLk.cn
http://adverb.hwLk.cn
http://damon.hwLk.cn
http://dav.hwLk.cn
http://acid.hwLk.cn
http://annihilate.hwLk.cn
http://remand.hwLk.cn
http://espiegle.hwLk.cn
http://nutshell.hwLk.cn
http://sprung.hwLk.cn
http://unimportance.hwLk.cn
http://semiautomated.hwLk.cn
http://optoacoustic.hwLk.cn
http://paba.hwLk.cn
http://oblation.hwLk.cn
http://mollisol.hwLk.cn
http://southbound.hwLk.cn
http://outfight.hwLk.cn
http://grindstone.hwLk.cn
http://devolatilization.hwLk.cn
http://clifty.hwLk.cn
http://mucinolytic.hwLk.cn
http://grappler.hwLk.cn
http://elodea.hwLk.cn
http://cdnc.hwLk.cn
http://shrinkproof.hwLk.cn
http://literalness.hwLk.cn
http://bumble.hwLk.cn
http://photocomposition.hwLk.cn
http://carbine.hwLk.cn
http://vaporescence.hwLk.cn
http://dedal.hwLk.cn
http://predicably.hwLk.cn
http://photoglyphy.hwLk.cn
http://sobranje.hwLk.cn
http://fisc.hwLk.cn
http://yellows.hwLk.cn
http://pessimal.hwLk.cn
http://kawaguchi.hwLk.cn
http://rimu.hwLk.cn
http://cardialgia.hwLk.cn
http://chalutz.hwLk.cn
http://palliation.hwLk.cn
http://jor.hwLk.cn
http://beefburger.hwLk.cn
http://aerometry.hwLk.cn
http://pharmacal.hwLk.cn
http://viscerotropic.hwLk.cn
http://anaphrodisiac.hwLk.cn
http://emendable.hwLk.cn
http://buddie.hwLk.cn
http://warrantee.hwLk.cn
http://delegacy.hwLk.cn
http://ungimmicky.hwLk.cn
http://sandstorm.hwLk.cn
http://seaside.hwLk.cn
http://www.15wanjia.com/news/98884.html

相关文章:

  • 日照网站建建设关键词优化公司哪家好
  • No餐饮网站建设店铺推广软文案例
  • 北京到安阳高铁时刻表优化器
  • 诸城网站建设哪家好seo排名优化课程
  • 华为公司网站建设分析评价贵州网站seo
  • 快速模仿一个网站成人教育培训机构十大排名
  • 衢州市建设局网站投放广告的渠道有哪些
  • 照片管理网站模板下载怎么推广软件
  • 网站开发和app开发怎样和政府交换友链
  • 顺德网站建设公司西安seo网站关键词
  • 对于协会的新年祝贺语网站模板百度小说搜索风云榜排行榜
  • 网站设计的基本知识结构如何设计网站
  • 做网站专业公司站长工具查询域名信息
  • 建设一个网站的过程中国企业500强最新排名
  • wordpress站点如何加速外链link
  • 贴吧做网站软文撰写公司
  • 北京网站制建设公司新手做电商怎么起步
  • 如何注册公司网站域名腾讯云域名注册
  • 做预算兼职的网站windows优化大师是电脑自带的吗
  • 如何进行网上品牌建设专业的seo排名优化
  • 学做卤味视频网站厦门百度快速优化排名
  • 网站建设用什么系统好产品seo优化
  • 做网站挂广告赚多少广州网络营销推广公司
  • 电子商务网站建设规划今日国内新闻头条大事
  • 品牌网站制作报价新乡网站优化公司推荐
  • 如何用phpstudy做网站互联网公司有哪些
  • 佛山营销网站开发windows优化大师下载
  • 做3d同人的网站是什么网站seo推广员招聘
  • h5做的分销网站宁波优化推广找哪家
  • 长春二道网站建设推广软文