Compare commits
4 Commits
master
...
stream-bri
| Author | SHA1 | Date | |
|---|---|---|---|
| bdd312cfba | |||
| c707a6dedc | |||
| b2ac356484 | |||
| 09d090a438 |
@@ -15,7 +15,12 @@ public class ConsumerApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Consumer<Date> receive() {
|
public Consumer<Date> sink1() {
|
||||||
|
return System.out::println;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Consumer<String> sink2() {
|
||||||
return System.out::println;
|
return System.out::println;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,20 @@ spring:
|
|||||||
host: 192.168.133.128
|
host: 192.168.133.128
|
||||||
username: dev-user
|
username: dev-user
|
||||||
password: devpassword
|
password: devpassword
|
||||||
|
|
||||||
cloud:
|
cloud:
|
||||||
stream:
|
stream:
|
||||||
bindings:
|
bindings:
|
||||||
input:
|
send1:
|
||||||
destination: my-test-channel
|
destination: test2
|
||||||
|
send2:
|
||||||
|
destination: test3
|
||||||
|
function:
|
||||||
|
# 定义别名
|
||||||
|
bindings:
|
||||||
|
sink1-in-0: send1
|
||||||
|
sink2-in-0: send2
|
||||||
|
definition: sink1;sink2
|
||||||
|
|
||||||
server:
|
server:
|
||||||
port: 8081
|
port: 8081
|
||||||
@@ -4,8 +4,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.cloud.stream.function.StreamBridge;
|
import org.springframework.cloud.stream.function.StreamBridge;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,10 +19,16 @@ public class Producer {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private StreamBridge streamBridge;
|
private StreamBridge streamBridge;
|
||||||
|
|
||||||
@RequestMapping("/send")
|
@RequestMapping("/send1")
|
||||||
public String send() {
|
public String send1() {
|
||||||
streamBridge.send(MySource.OUTPUT, new Date());
|
streamBridge.send("send1", new Date());
|
||||||
return "success";
|
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
|
host: 192.168.133.128
|
||||||
username: dev-user
|
username: dev-user
|
||||||
password: devpassword
|
password: devpassword
|
||||||
|
|
||||||
cloud:
|
cloud:
|
||||||
stream:
|
stream:
|
||||||
bindings:
|
bindings:
|
||||||
output:
|
send1:
|
||||||
destination: my-test-channel
|
destination: test2
|
||||||
|
send2:
|
||||||
|
destination: test3
|
||||||
|
|
||||||
|
|
||||||
server:
|
server:
|
||||||
port: 8082
|
port: 8083
|
||||||
Reference in New Issue
Block a user