赞
踩
最近在工作中会使用到spring cloud stream,网上中文资料几乎没有,阅读官网配置,好不容易搞定,在这里分享一下使用过程,也是自己做一个记录。
主页君自己使用场景是实现两个app之间的通信,第一个app输出数据,第二个app输入数据。这里的app也就是指一个service。
1.配置文件中进行绑定
app1中,配置输出通道相关信息。
application.yml
或者 application.properties
或者配置文件中,配置
spring:
cloud:
stream:
bindings:
output_channel: #channelName
destination: mydest #destination,或者可以认为是发布-订阅模型里面的topic
binder: rabbit1
binders:
rabbit1:
type: rabbit
environment:
spring:
rabbitmq:
host: 192.168.1.1 #rabbitMQ服务器地址
port: 5672 #rabbitMQ服务器端口
username: username
password: pwd
virtual-host: /hostName

app2中,配置输入通道相关信息。
spring:
cloud:
stream:
bindings:
input_cha
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。