消息订阅、发送成功

This commit is contained in:
2018-10-08 18:17:03 +08:00
commit 54d19c30cd
26 changed files with 650 additions and 0 deletions

25
consumer/consumer-server/.gitignore vendored Normal file
View File

@@ -0,0 +1,25 @@
/target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/build/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>consumer-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>consumer-server</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>top.fjy8018</groupId>
<artifactId>consumer</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>top.fjy8018</groupId>
<artifactId>consumer-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,18 @@
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);
}
}

View File

@@ -0,0 +1,12 @@
package top.fjy8018.consumer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ConsumerApplication {
public static void main(String[] args) {
SpringApplication.run(ConsumerApplication.class, args);
}
}

View File

@@ -0,0 +1,12 @@
spring:
rabbitmq:
host: docker-1.fjy8018.cn
username: cms
password: cms-mq-admin
cloud:
stream:
bindings:
input:
destination: my-test-channel
server:
port: 8081

View File

@@ -0,0 +1,16 @@
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() {
}
}