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

简述制作网站的步骤和过程wap门户

简述制作网站的步骤和过程,wap门户,电销外包团队在哪找,有口碑的盐城网站建设【RabbitMQ与SpringBoot集成测试收发消息】 一、环境说明二、实验步骤三、小结 一、环境说明 安装环境#xff1a;虚拟机VMWare Centos7.6 Maven3.6.3 JDK1.8RabbitMQ版本#xff1a;rabbitmq-server-3.8.8-1.el7.noarch.rpm编程工具Idea 运行JDK为17 二、实验步骤 在Rab… 【RabbitMQ与SpringBoot集成测试收发消息】 一、环境说明二、实验步骤三、小结 一、环境说明 安装环境虚拟机VMWare Centos7.6 Maven3.6.3 JDK1.8RabbitMQ版本rabbitmq-server-3.8.8-1.el7.noarch.rpm编程工具Idea 运行JDK为17 二、实验步骤 在RabbitMQ的UI界面或命令行上创建新的Virtual Host取名为vhtest02如下图所示 使用Idea的Spring Initializr创建生产者工程springrabbitmqtest坐标如下 配置application.properties可参考添加如下内容 spring.rabbitmq.host192.168.36.132 spring.rabbitmq.port5672 spring.rabbitmq.virtual-hostvhtest02 spring.rabbitmq.usernamesujiangming spring.rabbitmq.passwordopenGauss1234根据你自己的环境改成你自己的ip、port、virtual-host、用户名和密码。 编写生产者配置类用于创建Exchange、Queue以及将两者绑定在一起代码如下 类名为com.rabbitmq.springboot.config.RabbitMqConfig代码如下所示 package com.rabbitmq.springboot.config;import org.springframework.amqp.core.*; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;Configuration public class RabbitMqConfig {//创建交换机Bean(name topicExchange)public TopicExchange topicExchange(){return new TopicExchange(springboot_topic_exchange);}//创建队列Bean(name topicQueueSpringBoot)public Queue topicQueue(){return QueueBuilder.durable(springboot_topic_queue).build();}//队列绑定交换机Beanpublic Binding bindingExchangeTopicQueue(Qualifier(topicQueueSpringBoot) Queue queue,Qualifier(topicExchange)Exchange exchange){return BindingBuilder.bind(queue).to(exchange).with(log.#).noargs();} } 修改com.rabbitmq.springboot.SpringRabbitMqTestApplicationTests类添加注解和测试方法具体代码如下 package com.rabbitmq.springboot;import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner;RunWith(SpringRunner.class) SpringBootTest class SpringRabbitMqTestApplicationTests {Autowiredprivate RabbitTemplate rabbitTemplate;Testpublic void testSendMessage() throws InterruptedException {//convertAndSend(交换机名称路由key,消息内容)int temp 0;while (true){rabbitTemplate.convertAndSend(springboot_topic_exchange,log.info,发送了info消息 temp);rabbitTemplate.convertAndSend(springboot_topic_exchange,log.error,发送了error消息 temp);rabbitTemplate.convertAndSend(springboot_topic_exchange,log.warning,发送了warning消息 temp);temp;Thread.sleep(2000);}}Testvoid contextLoads() {}}该程序会一直运行因为我加了while(true)模拟用户一直产生数据。 运行测试运行com.rabbitmq.springboot.SpringRabbitMqTestApplicationTests类中的方法testSendMessage()正常运行会看到如下内容 编写消费者工程具体创建工程如步骤2所示 修改application.properties如步骤3所示可直接复步骤3内容即可 创建监听类com.rabbitmq.consumer.listener.MessageListener用于监听某个队列的消息一旦监听到有数据立马进行消费代码如下 package com.rabbitmq.consumer.listener;import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component;/*** 消息监听器*/ Component public class MessageListener {/*** 监听某个队列的消息* param msg 接收到的消息*/RabbitListener(queues springboot_topic_queue)public void topicListener(String msg){System.out.println(接收到消息 msg);} }修改启动类SpringbootRabbitmqConsumerApplication在其类上面添加注解ComponentScan(com.rabbitmq.consumer.*)如不添加该注解运行会自动退出修改好如下图所示 运行测试运行SpringbootRabbitmqConsumerApplication类正常情况下会看到如下内容 三、小结 本文参考了来自网络上的资料如有侵权请及时联系博主进行删除。本文仅是博主本人在学习过程中作为学习笔记使用常言道好记性不如烂笔头。如本文对您有所帮助请您动动发财的手指给博主点个赞谢谢您的阅读~~~
http://www.pierceye.com/news/731342/

相关文章:

  • 网站制作毕业设计滁州市建设局网站
  • saas建站和开源建站的区别比较高端的网页
  • 新公司董事长致辞做网站wordpress二次开发手册chm
  • 网站显示建设中大型企业网站制作
  • 长沙自动化网站建设wordpress 自定义栏目 调用
  • 吉大建设工程学院官方网站wordpress 文章图片插件
  • 赤峰中国建设招标网站网页设计素材网站推荐
  • 天津网站建设电焊机wordpress主题jenney
  • 个人网站制作wordpress英文注册查询网站
  • 哪里有免费网站空间申请wordpress重定向插件
  • 福州微网站开发什么样的网站快速盈利
  • 吉首市建设局官方网站一对一直播软件开发定制
  • 网站开发验收单做的网站如何被百度搜到
  • 网站的数据库是什么两学一做网站链接
  • 做窗帘网站济南网络科技公司排名
  • 广东省住房城乡建设部网站哪个网站可以做加工代理的
  • dede网站源码打包下载wordpress登不进后台
  • 建设内部网站目的国内贸易在那个网站上做
  • 用什么建设网站注册深圳公司代理
  • 网站平台建设方案书百度云资源搜索入口
  • 网站 团队博罗网站建设哪家便宜
  • wordpress列表分页枣庄seo外包
  • 知了网站后台推广形式有哪几种
  • 成品图片的网站在哪里找wordpress开启防盗链
  • 伊滨区网站建设网站建设经理
  • 权威的郑州网站建设域名租用平台
  • 造价工程师网网站点击排名优化
  • 网站关键词搜索海口网站建设优化公司
  • WordPress建影视站免费的素材网站有哪些
  • 屯留做网站哪里好阿里云服务器618