I cloned your code, even installed a JDK21. Got it working by moving the Person event class out of the Application class and into it’s own class.
Application.java
@SpringBootApplication
public class HelloWorldSpringCloudStreamApplication {
public static void main(String... args) {
SpringApplication.run(HelloWorldSpringCloudStreamApplication.class, args);
}
@Bean
public Consumer<PersonEvent> exampleEventConsumer() {
return personEvent -> {
System.out.println("Received event: " + personEvent.getName());
};
}
}
PersonEvent.java
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PersonEvent {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "PersonEvent, name="+name;
}
}
Also, you were escaping your quotes in your payload…? Here’s a handy command-line tool my colleague wrote that is useful for things like this:
Just download the latest release, that’s what I use:
$ ./stm send -t try-me -m '{"name":"Aaron"}'
Hope that’s enough to get you going now…! ??