Add (javax.)Validation Support for functional interface
For Stream binder there for support for the javax validation: https://github.com/spring-cloud/spring-cloud-stream/commit/d93f170f2e82319300b825c0437523353fc3c590
But it seams for the functional interface it is gone. It would expect this throwing a error when a message with invalid person name was received instead calling the log() method.
@SpringBootApplication
public class LoggingConsumerApplication {
public static void main(String[] args) {
SpringApplication.run(LoggingConsumerApplication.class, args);
}
@Bean
public Consumer<Message<@Valid Person>> log() {
return msg -> {
System.out.println("Received: " + msg.getPayload());
};
}
public static class Person {
private String name;
public String getName() {
return name;
}
@Pattern(regexp = "^[a-zA-Z_:][a-zA-Z0-9_:]*$")
public void setName(String name) {
this.name = name;
}
public String toString() {
return this.name;
}
}
}
I don't think that can work. You can't access the Annoations of a consumer according to my understanding (https://stackoverflow.com/questions/25702618/java-8-get-consumer-underlying-function-annotation). Spring CloudStream only can access the adhoc Implementation of the consumer which hides the real implementation.
Shure it can, it use very advanced reflection usage.
@GreenRover Do you have a tip for me on how to search? I have looked at the objects during debugging and have not found a starting point.