<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      SpringBoot整合RabbitMQ

      創(chuàng)建一個(gè)新工程-生產(chǎn)者

      1>改Pom

      <!--
              1. 父工程依賴
          -->
          <parent>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-parent</artifactId>
              <version>2.1.4.RELEASE</version>
          </parent>
      
          <dependencies>
              <!--2. rabbitmq-->
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-amqp</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-test</artifactId>
              </dependency>
          </dependencies>
      

      2>寫yml

      # 配置RabbitMQ的基本信息  ip 端口 username  password..
      spring:
        rabbitmq:
          host: 10.167.237.111 # ip
          port: 5672
          username: guest
          password: guest
          virtual-host: /
      

      3>啟動(dòng)類

      package com.leavscai7.rabbitmq;
      
      import org.springframework.boot.SpringApplication;
      import org.springframework.boot.autoconfigure.SpringBootApplication;
      
      /**
       * @Author: LeavesCai7
       * @Date: 2021/01/25 15:15
       */
      @SpringBootApplication
      public class ProducerApplication {
          public static void main(String[] args) {
              SpringApplication.run(ProducerApplication.class);
          }
      }
      

      4>配置類
      1、交換機(jī)
      2、Queue 隊(duì)列
      3、隊(duì)列和交換機(jī)綁定關(guān)系 Binding

      package com.leavscai7.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;
      
      /**
       * @Author: LeavesCai7
       * @Date: 2021/01/25 15:16
       */
      @Configuration
      public class RabbitMQConfig {
      
          public static final String EXCHANGE_NAME = "boot_topic_exchange";
          public static final String QUEUE_NAME = "boot_queue";
      
          //1.交換機(jī)
          @Bean("bootExchange")
          public Exchange bootExchange(){
              return ExchangeBuilder.topicExchange(EXCHANGE_NAME).durable(true).build();
          }
      
          //2.Queue 隊(duì)列
          @Bean("bootQueue")
          public Queue bootQueue(){
              return QueueBuilder.durable(QUEUE_NAME).build();
          }
      
          //3. 隊(duì)列和交互機(jī)綁定關(guān)系 Binding
          /*
              1. 知道哪個(gè)隊(duì)列
              2. 知道哪個(gè)交換機(jī)
              3. routing key
           */
          @Bean
          public Binding bindQueueExchange(@Qualifier("bootQueue") Queue queue, @Qualifier("bootExchange") Exchange exchange){
              return BindingBuilder.bind(queue).to(exchange).with("boot.#").noargs();
          }
      }
      

      5>測(cè)試類

      import com.leavescai7.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 ProducerTest {
      
          //1.注入RabbitTemplate
          @Autowired
          private RabbitTemplate rabbitTemplate;
      
          @Test
          public void testSend(){
      
              rabbitTemplate.convertAndSend(RabbitMQConfig.EXCHANGE_NAME,"boot.haha","boot mq hello~~~");
          }
      }
      
      posted on 2021-01-25 15:58  LeavesCai7  閱讀(81)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 日本在线a一区视频高清视频| 欧洲lv尺码大精品久久久| 又粗又硬又黄a级毛片| 国产精成人品日日拍夜夜| 亚洲性图日本一区二区三区| 国产精品高潮无码毛片| 康马县| 国产精品男女爽免费视频| 久久亚洲国产成人精品性色| 久久婷婷综合色一区二区| 亚洲精品一区二区口爆| 最新午夜男女福利片视频| 2019久久久高清日本道| 久久国产精品成人免费| 一本色道久久—综合亚洲| 久久夜色精品国产亚洲av| 人妻丝袜无码专区视频网站| 日韩少妇人妻vs中文字幕| 欧美在线观看www| 国产亚洲AV电影院之毛片| 1000部拍拍拍18勿入免费视频下载 | 国产中文字幕精品在线| 安远县| 亚洲乱码一二三四区| 在线视频中文字幕二区| 国产97人人超碰caoprom| 欧美日韩中文字幕久久伊人| 国产精品小视频一区二页| 国产小视频一区二区三区| 人妻丝袜无码专区视频网站| 蜜臀av入口一区二区三区| 无码人妻斩一区二区三区| 牛牛视频一区二区三区| 天天澡天天揉揉av无码| 天堂mv在线mv免费mv香蕉| 精品免费国产一区二区三区四区介绍| 一本无码在线观看| 精品一区二区三区蜜桃麻豆 | 日韩丝袜欧美人妻制服| 精品亚洲欧美高清不卡高清 | 粉嫩av一区二区三区蜜臀|