赞
踩
RabbitMQ是AMQP(Advanced Message Queuing Protocol,高级消息队列协议)规范的一种实现,用于在分布式系统中实现对消息的存储转发(Store and Forward)。Spring Boot集成RabbitMQ需要添加专门的依赖spring-boot-starter-amqp
。
父Maven模块与之前的文章中相同,详情请参阅SpringCloud集成Spring Data Redis
RabbitMQ的安装可以参考之前的文章: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>
application.yml
spring:
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
RabbitMQApplication
package com.lyc.springRabbitMQ;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springf
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。