Spring Cloud与RabbitMQ整合需要引入下述依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
<version>3.0.7.RELEASE</version>
</dependency>
配置文件application.yml中有如下配置:
spring:
cloud:
stream:
bindings:
# 消息的接收通道
input:
destination: default.messages
#传输内容的格式,如果是json的话,则为application/json
content-type: text/plain
binder: local_rabbit
#消息的发送通道
output:
destination: default.messages
#传输内容的格式,如果是json的话,则为application/json
content-type: text/plain
binder: local_rabbit
binders:
local_rabbit:
type: rabbit
environment:
spring: