We see some junk characters while deserialising the message
Hi Team,
I have question about junk characters in the payload message. In our use case, we consume the message from solace topics.
As part of solution, we used spring cloud stream,
fun consumer(): Consumer<Message> , the string payload when we log it, it is having junk characters like G?teborg instead of Götenborg example
We tried to decoded with UTF-8 but no luck, Is there something which we are missing. Has anyone seen this issue before? Any leads or support appreciated. Thank you
Best Answer
Answers
-
If anyone stumbles on this: probably the publisher was sending as TextMessage, which in Solace is a Structured Data Type (SDT) payload, where there is a single string wrapped with some additional bytes to indicate length. When deserializing, if the consumer just assumes the whole (binary blob) payload is a String, it'll see some extra junk chars. The consumer either needs to consume / cast as a Text Message (if using Solace APIs), or the publisher needs to publish a Bytes / binary message with the string as payload. If using REST Messaging, the "content type" probably needs to be set to
text/plain
.0