We see some junk characters while deserialising the message

Options
Setikam
Setikam Member Posts: 2
edited December 2021 in General Discussions #1

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

  • Setikam
    Setikam Member Posts: 2
    #2 Answer ✓
    Options

    I found out the problem and it is working now. Producer while serialising the message, they have not done in right way. It is solved. Thank you

Answers

  • Setikam
    Setikam Member Posts: 2
    #3 Answer ✓
    Options

    I found out the problem and it is working now. Producer while serialising the message, they have not done in right way. It is solved. Thank you

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 920 admin
    Options

    Glad you solved it and thanks for letting us know @Setikam 🙏

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 531 admin
    Options

    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.