Checking payload with Json schema

Hi @gerhardo,
I think what you’re asking is how do I ensure that when sending/receiving events using Spring Cloud Stream that they comply with an associated JSON Schema. Is that correct?

If yes, the Spring Cloud Stream framework does content-type negotiation to try to convert messages into POJOs that are defined in the method signature of the functions that are bound to the channels that messages are being exchanged over.

So for example in the Function below the framework will take the message payload and try to convert it into a Person POJO.

public Function<Person, Person> personFunction {..}

Because of this, one way to ensure your payloads match the schema is to generate your POJOs from your schemas and that is what is being done in the AsyncAPI Code Generator template for Spring Cloud Stream which you can find here.

Hope that helps! If you want to see how to use the generator you can check out my youtube video here

Note that I’m hoping to upgrade our Spring Cloud Stream samples soon :slight_smile:

-Marc