编程模型从命令式升级为函数式
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
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.getPayload());
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,10 @@ package top.fjy8018.consumer;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ConsumerApplication {
|
||||
@@ -9,4 +13,9 @@ public class ConsumerApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConsumerApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Consumer<Date> receive() {
|
||||
return System.out::println;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
spring:
|
||||
rabbitmq:
|
||||
host: 192.168.163.128
|
||||
username: cms
|
||||
password: cms-mq-admin
|
||||
host: 192.168.133.128
|
||||
username: dev-user
|
||||
password: devpassword
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package top.fjy8018.consumerserver;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class ConsumerServerApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user