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

重庆华鼎达网站建设厦门建设局电话多少

重庆华鼎达网站建设,厦门建设局电话多少,组织部建设网站示范材料,各级院建设网站的通知文章目录一.搭建SpringBoot环境二.配置1.配置application.yml2.定义RabbitConfig类三.生产端四.消费端一.搭建SpringBoot环境 我们选择基于Spring-Rabbit去操作RabbitMQ 使用spring-boot-starter-amqp会自动添加spring-rabbit依赖#xff0c;如下#xff1a; dependenc… 文章目录一.搭建SpringBoot环境二.配置1.配置application.yml2.定义RabbitConfig类三.生产端四.消费端一.搭建SpringBoot环境 我们选择基于Spring-Rabbit去操作RabbitMQ 使用spring-boot-starter-amqp会自动添加spring-rabbit依赖如下 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring‐boot‐starter‐amqp/artifactId /dependency dependencygroupIdorg.springframework.boot/groupIdartifactIdspring‐boot‐starter‐test/artifactId /dependency dependencygroupIdorg.springframework.boot/groupIdartifactIdspring‐boot‐starter‐logging/artifactId /dependency二.配置 1.配置application.yml 配置连接rabbitmq的参数 server:port: 44000 spring:application:name: test-rabbitmq-producerrabbitmq:host: 127.0.0.1port: 5672username: guestpassword: guestvirtualHost: /2.定义RabbitConfig类 定义RabbitConfig类配置Exchange、Queue、及绑定交换机 本例配置Topic交换机 package com.xuecheng.test.rabbitmq.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 {public static final String QUEUE_INFORM_EMAIL queue_inform_email;public static final String QUEUE_INFORM_SMS queue_inform_sms;public static final String EXCHANGE_TOPICS_INFORMexchange_topics_inform;public static final String ROUTINGKEY_EMAILinform.#.email.#;public static final String ROUTINGKEY_SMSinform.#.sms.#;//声明交换机Bean(EXCHANGE_TOPICS_INFORM)public Exchange EXCHANGE_TOPICS_INFORM(){//durable(true) 持久化mq重启之后交换机还在return ExchangeBuilder.topicExchange(EXCHANGE_TOPICS_INFORM).durable(true).build();}//声明QUEUE_INFORM_EMAIL队列Bean(QUEUE_INFORM_EMAIL)public Queue QUEUE_INFORM_EMAIL(){return new Queue(QUEUE_INFORM_EMAIL);}//声明QUEUE_INFORM_SMS队列Bean(QUEUE_INFORM_SMS)public Queue QUEUE_INFORM_SMS(){return new Queue(QUEUE_INFORM_SMS);}//ROUTINGKEY_EMAIL队列绑定交换机指定routingKeyBeanpublic Binding BINDING_QUEUE_INFORM_EMAIL(Qualifier(QUEUE_INFORM_EMAIL) Queue queue,Qualifier(EXCHANGE_TOPICS_INFORM) Exchange exchange){return BindingBuilder.bind(queue).to(exchange).with(ROUTINGKEY_EMAIL).noargs();}//ROUTINGKEY_SMS队列绑定交换机指定routingKeyBeanpublic Binding BINDING_ROUTINGKEY_SMS(Qualifier(QUEUE_INFORM_SMS) Queue queue,Qualifier(EXCHANGE_TOPICS_INFORM) Exchange exchange){return BindingBuilder.bind(queue).to(exchange).with(ROUTINGKEY_SMS).noargs();}} 三.生产端 使用RarbbitTemplate发送消息 package com.xuecheng.test.rabbitmq; import com.xuecheng.test.rabbitmq.config.RabbitmqConfig; import org.junit.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; SpringBootTest RunWith(SpringRunner.class) public class Producer05_topics_springboot { Autowired RabbitTemplate rabbitTemplate; Test public void testSendByTopics(){ for (int i0;i5;i){ String message sms email inform to useri; rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM,inform.sms.email,message); System.out.println(Send Message is: message ); } } }四.消费端 创建消费端工程添加依赖 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring‐boot‐starter‐amqp/artifactId /dependency dependencygroupIdorg.springframework.boot/groupIdartifactIdspring‐boot‐starter‐test/artifactId /dependency dependencygroupIdorg.springframework.boot/groupIdartifactIdspring‐boot‐starter‐logging/artifactId /dependency使用RabbitListener注解监听队列 package com.xuecheng.test.rabbitmq.mq; import com.rabbitmq.client.Channel; import com.xuecheng.test.rabbitmq.config.RabbitmqConfig; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component; Component public class ReceiveHandler { //监听email队列 RabbitListener(queues {RabbitmqConfig.QUEUE_INFORM_EMAIL}) public void receive_email(String msg,Message message,Channel channel){ System.out.println(msg); } / /监听sms队列 RabbitListener(queues {RabbitmqConfig.QUEUE_INFORM_SMS}) public void receive_sms(String msg,Message message,Channel channel){ System.out.println(msg); } }
http://www.zqtcl.cn/news/804449/

相关文章:

  • 长沙 网站运营德国服务器网站
  • 有动效网站建网站的书籍
  • 网站模版更新公告2023年ppt模板免费
  • 广饶网站建设北京建设工程监督网站
  • 长沙网站建设电话郑州网站空间
  • 做网站是怎样赚钱的网页制作工具按其制作方式有
  • 网站地图在哪里展现电子商务网站需要做那些准备工作
  • 深圳网站设计收费标准中端网站建设公司
  • 有关wordpress教学的网站wordpress返回旧版
  • php做网站弊端wordpress强大播放器
  • 怎么直接做免费网站wordpress如何自建站
  • 中国建设银行建银购网站金堂企业网站建设
  • 手机微网站开发的目的和意义温州公司网站开发
  • 除了外链 还有什么办法使网站提高排名网站建设珠海 新盈科技
  • 几分钟弄清楚php做网站中国风景摄影网
  • 卡片式网站网页设计公司的市场评估
  • 网站开发的感想wordpress水煮鱼
  • 网站开发入门培训机构自豪地采用wordpress更改
  • 手机网站来几个最近的国际新闻大事件
  • 重庆网站开发设计公司电话资源网站优化排名
  • 国土分局网站建设方案外贸seo网站
  • 营销型网站建设易网拓烟台h5网站建设公司
  • PHP网站开发都需要学什么中介网站模板
  • 网站建设与维护模板官方网站建设费用应入什么科目
  • 网站建设企业关键词seo关键词库
  • 美容院网站源码wordpress scandir
  • 长春电商网站建设报价北京创意设计协会网站
  • 企业3合1网站建设公司加强政协网站建设
  • 专业做互联网招聘的网站有哪些内容百度搜索引擎推广收费标准
  • 物流网站开发系统论文怎么知道网站程序是什么做的