4 Commits

Author SHA1 Message Date
bdd312cfba 移除无用配置 2021-02-21 13:56:41 +08:00
c707a6dedc 定义别名 2021-02-21 13:54:06 +08:00
b2ac356484 多主题配置 2021-02-21 11:45:41 +08:00
09d090a438 配置改进 2021-02-21 11:41:54 +08:00
4 changed files with 38 additions and 11 deletions

View File

@@ -15,7 +15,12 @@ public class ConsumerApplication {
}
@Bean
public Consumer<Date> receive() {
public Consumer<Date> sink1() {
return System.out::println;
}
@Bean
public Consumer<String> sink2() {
return System.out::println;
}
}

View File

@@ -3,10 +3,20 @@ spring:
host: 192.168.133.128
username: dev-user
password: devpassword
cloud:
stream:
bindings:
input:
destination: my-test-channel
send1:
destination: test2
send2:
destination: test3
function:
# 定义别名
bindings:
sink1-in-0: send1
sink2-in-0: send2
definition: sink1;sink2
server:
port: 8081

View File

@@ -4,8 +4,9 @@ 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.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
/**
@@ -18,10 +19,16 @@ public class Producer {
@Autowired
private StreamBridge streamBridge;
@RequestMapping("/send")
public String send() {
streamBridge.send(MySource.OUTPUT, new Date());
return "success";
@RequestMapping("/send1")
public String send1() {
streamBridge.send("send1", new Date());
return "success1";
}
@RequestMapping("/send2")
public String send2() {
streamBridge.send("send2", LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
return "success2";
}
}

View File

@@ -3,10 +3,15 @@ spring:
host: 192.168.133.128
username: dev-user
password: devpassword
cloud:
stream:
bindings:
output:
destination: my-test-channel
send1:
destination: test2
send2:
destination: test3
server:
port: 8082
port: 8083