类之间解耦
This commit is contained in:
@@ -11,6 +11,6 @@ import org.springframework.messaging.SubscribableChannel;
|
|||||||
public interface MySink {
|
public interface MySink {
|
||||||
String INPUT = "input";
|
String INPUT = "input";
|
||||||
|
|
||||||
@Input(Sink.INPUT)
|
@Input(MySink.INPUT)
|
||||||
SubscribableChannel input();
|
SubscribableChannel input();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ import org.springframework.messaging.MessageChannel;
|
|||||||
public interface MySource {
|
public interface MySource {
|
||||||
String OUTPUT = "output";
|
String OUTPUT = "output";
|
||||||
|
|
||||||
@Output("output")
|
@Output(MySource.OUTPUT)
|
||||||
MessageChannel output();
|
MessageChannel output();
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,6 @@ import top.fjy8018.consumer.common.MySink;
|
|||||||
public class Consumer {
|
public class Consumer {
|
||||||
@StreamListener(MySink.INPUT)
|
@StreamListener(MySink.INPUT)
|
||||||
public void receive(Message<String> message) {
|
public void receive(Message<String> message) {
|
||||||
System.out.println("接收到MQ消息:" + message);
|
System.out.println("接收到MQ消息:" + message.getPayload());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
spring:
|
spring:
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: docker-1.fjy8018.cn
|
host: 192.168.163.128
|
||||||
username: cms
|
username: cms
|
||||||
password: cms-mq-admin
|
password: cms-mq-admin
|
||||||
cloud:
|
cloud:
|
||||||
|
|||||||
@@ -20,12 +20,11 @@ import java.util.Date;
|
|||||||
public class Producer {
|
public class Producer {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Output(MySource.OUTPUT)
|
private MySource channel;
|
||||||
private MessageChannel channel;
|
|
||||||
|
|
||||||
@RequestMapping("/send")
|
@RequestMapping("/send")
|
||||||
public String send() {
|
public String send() {
|
||||||
channel.send(MessageBuilder.withPayload(new Date()).build());
|
channel.output().send(MessageBuilder.withPayload(new Date()).build());
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
spring:
|
spring:
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: docker-1.fjy8018.cn
|
host: 192.168.163.128
|
||||||
username: cms
|
username: cms
|
||||||
password: cms-mq-admin
|
password: cms-mq-admin
|
||||||
cloud:
|
cloud:
|
||||||
|
|||||||
Reference in New Issue
Block a user