From b2ac356484c33e085083c2a444d7bfef892361de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=E5=98=89=E9=98=B3?= Date: Sun, 21 Feb 2021 11:45:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E4=B8=BB=E9=A2=98=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../top/fjy8018/consumer/ConsumerApplication.java | 5 +++++ .../src/main/resources/application.yml | 4 +++- .../main/java/top/fjy8018/producer/Producer.java | 14 +++++++++++--- .../src/main/resources/application.yml | 4 +++- 4 files changed, 22 insertions(+), 5 deletions(-) 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 ebf2e52..2abc2f4 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 @@ -18,4 +18,9 @@ public class ConsumerApplication { public Consumer sink1() { return System.out::println; } + + @Bean + public Consumer sink2() { + 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 0f0e5a9..856bc8d 100644 --- a/consumer/consumer-server/src/main/resources/application.yml +++ b/consumer/consumer-server/src/main/resources/application.yml @@ -9,8 +9,10 @@ spring: bindings: sink1-in-0: destination: test2 + sink2-in-0: + destination: test3 function: - definition: sink1 + definition: sink1;sink2 server: 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 b147083..e760990 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 @@ -5,6 +5,8 @@ import org.springframework.cloud.stream.function.StreamBridge; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Date; /** @@ -17,10 +19,16 @@ public class Producer { @Autowired private StreamBridge streamBridge; - @RequestMapping("/send") - public String send() { + @RequestMapping("/send1") + public String send1() { streamBridge.send("source1-out-0", new Date()); - return "success"; + return "success1"; + } + + @RequestMapping("/send2") + public String send2() { + streamBridge.send("source2-out-0", LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)); + return "success2"; } } diff --git a/producer/producer-server/src/main/resources/application.yml b/producer/producer-server/src/main/resources/application.yml index 36d7825..b90191c 100644 --- a/producer/producer-server/src/main/resources/application.yml +++ b/producer/producer-server/src/main/resources/application.yml @@ -9,8 +9,10 @@ spring: bindings: source1-out-0: destination: test2 + source2-out-0: + destination: test3 function: - definition: source1 + definition: source1;source2 server: