Spring Cloud Stream Microservice Deserialize Messages

Hello,

I have set up a Spring Cloud Stream microservice with the solace configuration. This microservice has been able to take in payloads of type string or java object, but I am now receiving SpB (protobuf) messages through solace. My goal is to deserialize these messages to JSON or POJO to be able to actually work with the data, but I have been unsuccessful at doing so.

I was wondering if Spring Cloud Stream has the functionality built in to deserialize messages of this type in an easy manner. I have been looking into @StreamListener of spring cloud stream but have not been able to get it working and do not fully understand how it works.

In addition, I have tried implementing the Eclipse Tahu project (tahu/sparkplug_b at master · eclipse-tahu/tahu · GitHub) into my microservice project but it has not been working and I feel as there must be an easier way to deserialize these messages. Please let me know if anyone knows how to go about this!

I also believe there needs to be some edits on the application.yml file of the project to declare what message type the microservice should expect to receive, but am not sure how it would look in this case. Please correct me if I’m wrong!

Thank you, Joseph

Hi @bensabat,

Yes this is definitely possible! I don’t have a protobuf example, but you’ll want to start in the Spring Cloud Stream reference guide.

Another note, the annotation style of creating a Cloud Stream app has been deprecated so I’d suggest against using that style. Instead code your microservice using Spring Cloud Function.

Hope that helps!

Also, from a quick google I found this example: protocol-buffers-spring-cloud-stream/protocol-buffers-spring-cloud-stream-starter/src/main/java/io/disc99/protocol/buffers/spring/cloud/stream at master · disc99/protocol-buffers-spring-cloud-stream · GitHub

Take a look and see if that helps create the MessageConverter, but keep in mind that it’s using the old annotation style for the actual coding of the app. I think you should be able to re-use the MessageConverter though.

Let us know how it goes :slight_smile:

Hi @marc ,

Thank you for your response. I have been trying your approach but there is still some configuration and understanding that I have not been able to figure out. I’ve sent you a message regarding this!

Thanks, Joseph