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

保健品网站可以做网站手机微网站怎么做的

保健品网站可以做网站,手机微网站怎么做的,高层网络架构,旅游开发 网站建设一、简介 在Spring项目中#xff0c;可以使用Spring-Rabbit去操作RabbitMQ 尤其是在spring boot项目中只需要引入对应的amqp启动器依赖即可#xff0c;方便的使用RabbitTemplate发送消息#xff0c;使用注解接收消息。 一般在开发过程中#xff1a; 生产者工程#xf…一、简介 在Spring项目中可以使用Spring-Rabbit去操作RabbitMQ 尤其是在spring boot项目中只需要引入对应的amqp启动器依赖即可方便的使用RabbitTemplate发送消息使用注解接收消息。 一般在开发过程中 生产者工程 application.yml文件配置相关信息在生产者工程中编写配置类用于创建交换机和队列并进行绑定注入RabbitTemplate对象通过RabbitTemplate对象发送消息到交换机 消费者工程 application.yml文件配置相关信息创建消息处理类用于接收队列中的消息并进行处理 二、项目结构 三、加入依赖jar dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-amqp/artifactId /dependency 四、编写配置文件 spring:rabbitmq:username: userpassword: 123456virtual-host: /adminport: 5672 mq:exchange:name: test_exchange_topicqueue:name1: test_topic_exchange_queue1name2: test_topic_exchange_queue2 五、编写配置类 import org.springframework.amqp.core.*; import org.springframework.amqp.core.ExchangeBuilder; import org.springframework.amqp.core.QueueBuilder; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;Configuration public class TopicConfig {Value(${mq.exchange.name})private String EXCHANGENAME;Value(${mq.queue.name1})private String QUEUENAME1;Value(${mq.queue.name2})private String QUEUENAME2;Bean(Exchange)public Exchange getExchange(){Exchange exchange ExchangeBuilder.topicExchange(EXCHANGENAME).durable(false).build();return exchange;}Bean(Queue1)public Queue getQueue1(){Queue build QueueBuilder.nonDurable(QUEUENAME1).build();return build;}Bean(Queue2)public Queue getQueue2(){Queue build QueueBuilder.nonDurable(QUEUENAME2).build();return build;}Bean(Binding1)public Binding bindingQueueToExchange1(Qualifier(Exchange)Exchange exchange,Qualifier(Queue1) Queue queue){Binding noargs BindingBuilder.bind(queue).to(exchange).with(test.#).noargs();return noargs;}Bean(Binding2)public Binding bindingQueueToExchange2(Qualifier(Exchange)Exchange exchange,Qualifier(Queue2) Queue queue){Binding noargs BindingBuilder.bind(queue).to(exchange).with(test.*).noargs();return noargs;} } 六、测试类 import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest;import javax.annotation.Resource;SpringBootTest public class ProductTest {Value(${mq.exchange.name})private String EXCHANGENAME;ResourceRabbitTemplate rabbitTemplate;org.junit.jupiter.api.Testpublic void t1(){rabbitTemplate.convertAndSend(EXCHANGENAME,test.t,随便测试);} } 七. 消费者消费消息 Component public class Comm {RabbitListener(queues test_topic_exchange_queue1)public void t1(Message message){byte[] body message.getBody();String string new String(body);System.out.println(string----------------);}}八、消息的可靠性传递 1.Confirm (1) 修改application.yml文件 (2) 写一个测试类 SpringBootTest public class ProductTest {Value(${mq.exchange.name})private String EXCHANGENAME;ResourceRabbitTemplate rabbitTemplate;org.junit.jupiter.api.Testpublic void t2(){rabbitTemplate.setConfirmCallback(new RabbitTemplate.ConfirmCallback() {Overridepublic void confirm(CorrelationData correlationData, boolean b, String s) {if (b) {System.out.println(发送成功);}else {System.out.println(发送不成功s);}}});rabbitTemplate.convertAndSend(EXCHANGENAME,test.t,随便测试);} } 2. Return (1) 配置文件中设置回退模式 spring:rabbitmq:username: userpassword: 123456virtual-host: /adminport: 5672host: 192.168.44.64publisher-returns: true # publisher-confirm-type: correlated mq:exchange:name: test_exchange_topicqueue:name1: test_topic_exchange_queue1name2: test_topic_exchange_queue2 (2) 测试 import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest;import javax.annotation.Resource;SpringBootTest public class ProductTest {Value(${mq.exchange.name})private String EXCHANGENAME;ResourceRabbitTemplate rabbitTemplate;org.junit.jupiter.api.Testpublic void t1(){rabbitTemplate.convertAndSend(EXCHANGENAME,test.t,随便测试);}org.junit.jupiter.api.Testpublic void t2(){rabbitTemplate.setConfirmCallback(new RabbitTemplate.ConfirmCallback() {Overridepublic void confirm(CorrelationData correlationData, boolean b, String s) {if (b) {System.out.println(发送成功);}else {System.out.println(发送不成功s);}}});rabbitTemplate.convertAndSend(EXCHANGENAME,test.t,随便测试);}org.junit.jupiter.api.Testpublic void t3(){rabbitTemplate.setMandatory(true);rabbitTemplate.setReturnsCallback(returnedMessage -System.out.println(消息回退new String(returnedMessage.getMessage().getBody())));rabbitTemplate.convertAndSend(EXCHANGENAME,test.a,测试测试);} }
http://www.pierceye.com/news/786307/

相关文章:

  • 厦门建网站费用一览表网站建设与管理ppt模板下载
  • 做赌场网站犯法么网站开发培训成都
  • 网站建设系统怎么样企业策划是做什么的
  • 做网站要不要钱网站如何做触屏滑动
  • 加工企业网站这么做常德网站建设企业
  • 百度举报网站wordpress主题缩略图
  • 南宁快速网站建设电话WordPress电影公司网站
  • 什么网站可以直接做word文档亚马逊周末可以视频认证吗
  • 网站设计申请书买购网官方网站
  • 深圳做网站建设公司青岛网景互联网站建设公司
  • 做公司网站要多少钱洛阳信息网
  • asp 网站名字免费的公众号排版工具
  • 郑州响应式建站查企业的信息在哪个官网
  • 大型企业网站开发怎么使用免费的wordpress
  • 大连做网站大公司建设项目咨询公司网站
  • 教育培训网站建设方案鞍山建设信息网站
  • 重庆网站建设哪家强平台如何做推广
  • 安徽省建设安全监督站的网站网站建设公司一般多少钱
  • 服装网站建设策划书3000字软件开发包含网站开发吗
  • 免费网站的建设绵阳网站建设制作
  • 学生处网站建设招标公告网站包括哪些主要内容
  • 成都门户网站建设多少钱聚合广告联盟
  • 坦克大战网站开发课程设计报告软文营销的本质
  • 美食网站开发网站登录验证码是怎么做的
  • 电子商务网站排名辽宁省建设工程信息网业绩公示
  • 天津建设科技杂志的官方网站wordpress cnzz插件
  • 滨州建设网站太原网站建设优化
  • 记事本做网站怎么改字体包装设计模板设计素材
  • 下载软件的网站推荐thinkphp和wordpress
  • 青海省城乡和住房建设厅网站合肥小吃培训网页设计