Message published but cant figure out the error.

Hello I am new to Solace. I want to publish messages to solace.
I have messages in JSON format which I convert in bytes and then publish it. At the receiver’s end we can see that the messgae is receieved but I get the following error.

"Exception is class com.solacesystems.jms.message.SolMessage cannot be cast to class com.solacesystems.jms.message.SolBytesMessage (com.solacesystems.jms.message.SolMessage and com.solacesystems.jms.message.SolBytesMessage are in unnamed module of loader ‘app’)

ABC Number is null

Found a Text encoded message "

I am using python script to do this. Please if someone could help and have face similar issues earlier. Let me know.

Hey @Amey - I was able to run the solace python samples just now with a json body and the receiver was able to json.loads() the body. Are you able to run the samples here

It sounds like you’re trying to consume your Python-published message using JMS? Trying to guess from your exception / error text above, are you trying to cast a received JMS message to a BytesMessage without checking if it is…? Looks like it could be a TextMessage .

Maybe your JMS consumer needs to do something like:


if (msg instanceof TextMessage) {
    TextMessage txt = (TextMessage)msg;
    String payload = txt.getText();
    // more here
} else if (msg instanceof BytesMessage) {
    BytesMessage bytes = (BytesMessage)msg;
    // more here
} else // blah blah

Also, when you mention you want to “convert your JSON to bytes”, what does that mean? Like, serialize it to AVRO as a binary format payload? Or just send the JSON string as a binary message? Or …?