From 1b8e541d68f897b6fbe9f3e305b301b9e9e85d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=E5=98=89=E9=98=B3?= Date: Sun, 21 Feb 2021 10:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E6=A8=A1=E5=9E=8B=E4=BB=8E?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E5=BC=8F=E5=8D=87=E7=BA=A7=E4=B8=BA=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/ConsumerCommonApplicationTests.java | 16 ---------------- .../java/top/fjy8018/consumer/Consumer.java | 18 ------------------ .../fjy8018/consumer/ConsumerApplication.java | 9 +++++++++ .../src/main/resources/application.yml | 6 +++--- .../ConsumerServerApplicationTests.java | 16 ---------------- consumer/pom.xml | 2 +- pom.xml | 6 +++--- producer/pom.xml | 2 +- .../common/ProducerCommonApplicationTests.java | 16 ---------------- .../java/top/fjy8018/producer/Producer.java | 11 ++++------- .../src/main/resources/application.yml | 6 +++--- .../server/ProducerServerApplicationTests.java | 16 ---------------- 12 files changed, 24 insertions(+), 100 deletions(-) delete mode 100644 consumer/consumer-common/src/test/java/top/fjy8018/consumer/common/ConsumerCommonApplicationTests.java delete mode 100644 consumer/consumer-server/src/main/java/top/fjy8018/consumer/Consumer.java delete mode 100644 consumer/consumer-server/src/test/java/top/fjy8018/consumerserver/ConsumerServerApplicationTests.java delete mode 100644 producer/producer-common/src/test/java/top/fjy8018/producer/common/ProducerCommonApplicationTests.java delete mode 100644 producer/producer-server/src/test/java/top/fjy8018/producer/server/ProducerServerApplicationTests.java diff --git a/consumer/consumer-common/src/test/java/top/fjy8018/consumer/common/ConsumerCommonApplicationTests.java b/consumer/consumer-common/src/test/java/top/fjy8018/consumer/common/ConsumerCommonApplicationTests.java deleted file mode 100644 index d30280f..0000000 --- a/consumer/consumer-common/src/test/java/top/fjy8018/consumer/common/ConsumerCommonApplicationTests.java +++ /dev/null @@ -1,16 +0,0 @@ -package top.fjy8018.consumer.common; - -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 ConsumerCommonApplicationTests { - - @Test - public void contextLoads() { - } - -} diff --git a/consumer/consumer-server/src/main/java/top/fjy8018/consumer/Consumer.java b/consumer/consumer-server/src/main/java/top/fjy8018/consumer/Consumer.java deleted file mode 100644 index 94a6ac1..0000000 --- a/consumer/consumer-server/src/main/java/top/fjy8018/consumer/Consumer.java +++ /dev/null @@ -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 message) { - System.out.println("接收到MQ消息:" + message.getPayload()); - } -} \ No newline at end of file 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 3a8fe6e..60ed340 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 @@ -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 receive() { + 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 66d3e3a..038031b 100644 --- a/consumer/consumer-server/src/main/resources/application.yml +++ b/consumer/consumer-server/src/main/resources/application.yml @@ -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: diff --git a/consumer/consumer-server/src/test/java/top/fjy8018/consumerserver/ConsumerServerApplicationTests.java b/consumer/consumer-server/src/test/java/top/fjy8018/consumerserver/ConsumerServerApplicationTests.java deleted file mode 100644 index bca1a63..0000000 --- a/consumer/consumer-server/src/test/java/top/fjy8018/consumerserver/ConsumerServerApplicationTests.java +++ /dev/null @@ -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() { - } - -} diff --git a/consumer/pom.xml b/consumer/pom.xml index 8cab1b8..b5b0020 100644 --- a/consumer/pom.xml +++ b/consumer/pom.xml @@ -5,7 +5,7 @@ consumer 0.0.1-SNAPSHOT - jar + pom consumer Demo project for Spring Boot diff --git a/pom.xml b/pom.xml index f560953..8e8034c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ top.fjy8018 cloud-stream 0.0.1-SNAPSHOT - jar + pom cloud-stream Demo project for Spring Boot @@ -19,7 +19,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.5.RELEASE + 2.4.2 @@ -27,7 +27,7 @@ UTF-8 UTF-8 1.8 - Finchley.SR1 + 2020.0.1 0.0.1-SNAPSHOT diff --git a/producer/pom.xml b/producer/pom.xml index 2cb9494..91482a3 100644 --- a/producer/pom.xml +++ b/producer/pom.xml @@ -5,7 +5,7 @@ producer 0.0.1-SNAPSHOT - jar + pom producer-common diff --git a/producer/producer-common/src/test/java/top/fjy8018/producer/common/ProducerCommonApplicationTests.java b/producer/producer-common/src/test/java/top/fjy8018/producer/common/ProducerCommonApplicationTests.java deleted file mode 100644 index 69244f0..0000000 --- a/producer/producer-common/src/test/java/top/fjy8018/producer/common/ProducerCommonApplicationTests.java +++ /dev/null @@ -1,16 +0,0 @@ -package top.fjy8018.producer.common; - -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 ProducerCommonApplicationTests { - - @Test - public void contextLoads() { - } - -} 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 95158c6..377e807 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,10 +1,7 @@ package top.fjy8018.producer; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.annotation.Output; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.support.MessageBuilder; +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; @@ -16,15 +13,15 @@ import java.util.Date; * @date 2018-10-08 17:57 */ @RestController -@EnableBinding(MySource.class) public class Producer { @Autowired - private MySource channel; + private StreamBridge streamBridge; @RequestMapping("/send") public String send() { - channel.output().send(MessageBuilder.withPayload(new Date()).build()); + streamBridge.send(MySource.OUTPUT, new Date()); return "success"; } + } diff --git a/producer/producer-server/src/main/resources/application.yml b/producer/producer-server/src/main/resources/application.yml index 63c78c1..5dc18c3 100644 --- a/producer/producer-server/src/main/resources/application.yml +++ b/producer/producer-server/src/main/resources/application.yml @@ -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: diff --git a/producer/producer-server/src/test/java/top/fjy8018/producer/server/ProducerServerApplicationTests.java b/producer/producer-server/src/test/java/top/fjy8018/producer/server/ProducerServerApplicationTests.java deleted file mode 100644 index 40768a7..0000000 --- a/producer/producer-server/src/test/java/top/fjy8018/producer/server/ProducerServerApplicationTests.java +++ /dev/null @@ -1,16 +0,0 @@ -package top.fjy8018.producer.server; - -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 ProducerServerApplicationTests { - - @Test - public void contextLoads() { - } - -}