Compare commits
1 Commits
stream-bri
...
functional
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d9c821d11 |
@@ -15,7 +15,7 @@ public class ConsumerApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Consumer<Date> receive() {
|
public Consumer<Date> sink1() {
|
||||||
return System.out::println;
|
return System.out::println;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:
|
||||||
input:
|
sink1-in-0:
|
||||||
destination: my-test-channel
|
destination: test1
|
||||||
|
function:
|
||||||
|
definition: sink1
|
||||||
|
|
||||||
|
|
||||||
server:
|
server:
|
||||||
port: 8081
|
port: 8081
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
package top.fjy8018.producer;
|
package top.fjy8018.producer;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import top.fjy8018.consumer.common.MySource;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author F嘉阳
|
* @author F嘉阳
|
||||||
@@ -16,11 +15,11 @@ import java.util.Date;
|
|||||||
public class Producer {
|
public class Producer {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private StreamBridge streamBridge;
|
private Supplier<Date> supplier;
|
||||||
|
|
||||||
@RequestMapping("/send")
|
@RequestMapping("/send")
|
||||||
public String send() {
|
public String send() {
|
||||||
streamBridge.send(MySource.OUTPUT, new Date());
|
supplier.get();
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ package top.fjy8018.producer;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class ProducerApplication {
|
public class ProducerApplication {
|
||||||
@@ -9,4 +13,9 @@ public class ProducerApplication {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ProducerApplication.class, args);
|
SpringApplication.run(ProducerApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Supplier<Date> source1() {
|
||||||
|
return () -> new Date();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:
|
source1-out-0:
|
||||||
destination: my-test-channel
|
destination: test1
|
||||||
|
function:
|
||||||
|
definition: source1
|
||||||
|
|
||||||
|
|
||||||
server:
|
server:
|
||||||
port: 8082
|
port: 8083
|
||||||
Reference in New Issue
Block a user