消息订阅、发送成功
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package top.fjy8018.consumer;
|
||||
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
import org.springframework.cloud.stream.annotation.StreamListener;
|
||||
import org.springframework.messaging.Message;
|
||||
import top.fjy8018.consumer.common.MySink;
|
||||
|
||||
/**
|
||||
* @author F嘉阳
|
||||
* @date 2018-10-08 18:10
|
||||
*/
|
||||
@EnableBinding(MySink.class)
|
||||
public class Consumer {
|
||||
@StreamListener(MySink.INPUT)
|
||||
public void receive(Message<String> message) {
|
||||
System.out.println("接收到MQ消息:" + message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package top.fjy8018.consumer;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ConsumerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConsumerApplication.class, args);
|
||||
}
|
||||
}
|
||||
12
consumer/consumer-server/src/main/resources/application.yml
Normal file
12
consumer/consumer-server/src/main/resources/application.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
spring:
|
||||
rabbitmq:
|
||||
host: docker-1.fjy8018.cn
|
||||
username: cms
|
||||
password: cms-mq-admin
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
input:
|
||||
destination: my-test-channel
|
||||
server:
|
||||
port: 8081
|
||||
Reference in New Issue
Block a user