Binder sample app uses complex types
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.springframework.pulsar.sample.binder;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -29,7 +30,7 @@ import org.springframework.context.annotation.Bean;
|
||||
@SpringBootApplication
|
||||
public class SpringPulsarBinderSampleApp {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SpringPulsarBinderSampleApp.class);
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringPulsarBinderSampleApp.class, args);
|
||||
@@ -41,8 +42,16 @@ public class SpringPulsarBinderSampleApp {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Consumer<String> timeLogger() {
|
||||
return s -> this.logger.info("Hello binder: " + s);
|
||||
public Function<String, EnhancedTime> timeProcessor() {
|
||||
return (rawTime) -> new EnhancedTime(rawTime, "5150");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Consumer<EnhancedTime> timeLogger() {
|
||||
return (time) -> this.logger.info("TIME -> {}", time);
|
||||
}
|
||||
|
||||
record EnhancedTime(String time, String extra) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,37 @@
|
||||
spring:
|
||||
cloud:
|
||||
function:
|
||||
definition: timeSupplier;timeLogger
|
||||
definition: timeSupplier;timeProcessor;timeLogger;
|
||||
stream:
|
||||
bindings:
|
||||
timeLogger-in-0:
|
||||
destination: timeSupplier-out-0
|
||||
consumer:
|
||||
use-native-decoding: true
|
||||
timeSupplier-out-0:
|
||||
producer:
|
||||
use-native-encoding: true
|
||||
timeProcessor-in-0:
|
||||
destination: timeSupplier-out-0
|
||||
consumer:
|
||||
use-native-decoding: true
|
||||
timeProcessor-out-0:
|
||||
destination: timeProcessor-out-0
|
||||
producer:
|
||||
use-native-encoding: true
|
||||
timeLogger-in-0:
|
||||
destination: timeProcessor-out-0
|
||||
consumer:
|
||||
use-native-decoding: true
|
||||
pulsar:
|
||||
bindings:
|
||||
timeLogger-in-0:
|
||||
consumer:
|
||||
schema-type: STRING
|
||||
timeSupplier-out-0:
|
||||
producer:
|
||||
schema-type: STRING
|
||||
schema-type: STRING
|
||||
timeProcessor-in-0:
|
||||
consumer:
|
||||
schema-type: STRING
|
||||
timeProcessor-out-0:
|
||||
producer:
|
||||
schema-type: JSON
|
||||
message-type: org.springframework.pulsar.sample.binder.SpringPulsarBinderSampleApp.EnhancedTime
|
||||
timeLogger-in-0:
|
||||
consumer:
|
||||
schema-type: JSON
|
||||
message-type: org.springframework.pulsar.sample.binder.SpringPulsarBinderSampleApp.EnhancedTime
|
||||
|
||||
Reference in New Issue
Block a user