diff --git a/consumer/consumer-server/src/main/java/top/fjy8018/consumer/ConsumerApplication.java b/consumer/consumer-server/src/main/java/top/fjy8018/consumer/ConsumerApplication.java index 60ed340..ebf2e52 100644 --- a/consumer/consumer-server/src/main/java/top/fjy8018/consumer/ConsumerApplication.java +++ b/consumer/consumer-server/src/main/java/top/fjy8018/consumer/ConsumerApplication.java @@ -15,7 +15,7 @@ public class ConsumerApplication { } @Bean - public Consumer receive() { + public Consumer sink1() { return System.out::println; } } diff --git a/consumer/consumer-server/src/main/resources/application.yml b/consumer/consumer-server/src/main/resources/application.yml index 038031b..59a2c74 100644 --- a/consumer/consumer-server/src/main/resources/application.yml +++ b/consumer/consumer-server/src/main/resources/application.yml @@ -3,10 +3,15 @@ spring: host: 192.168.133.128 username: dev-user password: devpassword + cloud: stream: bindings: - input: - destination: my-test-channel + sink1-in-0: + destination: test1 + function: + definition: sink1 + + server: port: 8081 \ No newline at end of file diff --git a/producer/producer-server/src/main/java/top/fjy8018/producer/Producer.java b/producer/producer-server/src/main/java/top/fjy8018/producer/Producer.java index 377e807..1490a58 100644 --- a/producer/producer-server/src/main/java/top/fjy8018/producer/Producer.java +++ b/producer/producer-server/src/main/java/top/fjy8018/producer/Producer.java @@ -1,12 +1,11 @@ package top.fjy8018.producer; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.stream.function.StreamBridge; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import top.fjy8018.consumer.common.MySource; import java.util.Date; +import java.util.function.Supplier; /** * @author F嘉阳 @@ -16,11 +15,11 @@ import java.util.Date; public class Producer { @Autowired - private StreamBridge streamBridge; + private Supplier supplier; @RequestMapping("/send") public String send() { - streamBridge.send(MySource.OUTPUT, new Date()); + supplier.get(); return "success"; } diff --git a/producer/producer-server/src/main/java/top/fjy8018/producer/ProducerApplication.java b/producer/producer-server/src/main/java/top/fjy8018/producer/ProducerApplication.java index 8af2dcb..45ccfa9 100644 --- a/producer/producer-server/src/main/java/top/fjy8018/producer/ProducerApplication.java +++ b/producer/producer-server/src/main/java/top/fjy8018/producer/ProducerApplication.java @@ -2,6 +2,10 @@ package top.fjy8018.producer; 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.Supplier; @SpringBootApplication public class ProducerApplication { @@ -9,4 +13,9 @@ public class ProducerApplication { public static void main(String[] args) { SpringApplication.run(ProducerApplication.class, args); } + + @Bean + public Supplier source1() { + return () -> new Date(); + } } diff --git a/producer/producer-server/src/main/resources/application.yml b/producer/producer-server/src/main/resources/application.yml index 5dc18c3..c74c4de 100644 --- a/producer/producer-server/src/main/resources/application.yml +++ b/producer/producer-server/src/main/resources/application.yml @@ -3,10 +3,15 @@ spring: host: 192.168.133.128 username: dev-user password: devpassword + cloud: stream: bindings: - output: - destination: my-test-channel + source1-out-0: + destination: test1 + function: + definition: source1 + + server: - port: 8082 \ No newline at end of file + port: 8083 \ No newline at end of file