rabbitmq 與stream 結(jié)合入門應(yīng)用舉例:
一、消息生產(chǎn)者:
1、引入依賴:
<dependencies>
? ? ? ? <dependency>
? ? ? ? ? ? <groupId>org.springframework.cloud</groupId>
? ? ? ? ? ? <artifactId>spring-cloud-stream</artifactId>
? ? ? ? </dependency>
? ? ? ? <dependency>
? ? ? ? ? ? <groupId>org.springframework.cloud</groupId>
? ? ? ? ? ? <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
? ? ? ? </dependency>
? ? ? ? <dependency>
? ? ? ? ? ? <groupId>org.springframework.cloud</groupId>
? ? ? ? ? ? <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
? ? ? ? </dependency>
? ? </dependencies>

2、配置yml 文件:
如果用內(nèi)置接口,不會用到下面的 myoutput: 這個配置,可以刪除,

3、定義消息發(fā)送接口, spring 內(nèi)置的一個消息發(fā)送接口已經(jīng)有一個:
public interface Source {? ??
String OUTPUT = "output";
@Output("output") ?
MessageChannel output();
}
4、發(fā)送消息

二、消息消費者
1、引入和消息生產(chǎn)者一樣的依賴

2/消費者中的對應(yīng)配置


3、定義消息接收接口, spring 內(nèi)置的一個消息接收接口已經(jīng)有一個:
public interface Sink {? ?
String INPUT = "input";
? ?@Input("input") ? ?
SubscribableChannel input();?
}
4、接收消息:
