Compare commits
4 Commits
master
...
stream-bri
| Author | SHA1 | Date | |
|---|---|---|---|
| bdd312cfba | |||
| c707a6dedc | |||
| b2ac356484 | |||
| 09d090a438 |
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user