当前位置:   article > 正文

SpringCloud集成RabbitMQ_spring cloud集成rabbitmq

spring cloud集成rabbitmq

RabbitMQ

  RabbitMQ是AMQP(Advanced Message Queuing Protocol,高级消息队列协议)规范的一种实现,用于在分布式系统中实现对消息的存储转发(Store and Forward)。Spring Boot集成RabbitMQ需要添加专门的依赖spring-boot-starter-amqp

源码

  父Maven模块与之前的文章中相同,详情请参阅SpringCloud集成Spring Data Redis

  RabbitMQ的安装可以参考之前的文章:RabbitMQ的安装

spring-rabbitmq

  pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>springcloud-parent2</artifactId>
        <groupId>com.lyc</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>spring-rabbitmq</artifactId>

    <name>spring-rabbitmq</name>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
        </dependency>
    </dependencies>

</project>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

  application.yml

spring:
  rabbitmq:
    host: localhost
    port: 5672
    username: guest
    password: guest
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

  RabbitMQApplication

package com.lyc.springRabbitMQ;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springf
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/925938
推荐阅读
相关标签
  

闽ICP备14008679号