Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change MessageConverter.fromMessage()'s parameter Type from String to byte[] #534

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gepengjun
Copy link

What is the purpose of the change

i think byte[] is more suitable for the most MessageConverter than String, byte[] is suitable the current MessageConverters such as
ByteArrayMessageConverter, StringMessageConverter, MappingJackson2MessageConverter, MappingFastJsonMessageConverter,
and it is yet suitable for ProtobufMessageConverter;

@gepengjun
Copy link
Author

gepengjun commented Mar 2, 2023

i want to serialize and deserialize the message with ProtobufMessageConverter so i define RocketMQMessageConverter like this
@bean
public RocketMQMessageConverter rocketMQMessageConverter(ProtobufMessageConverter protobufMessageConverter){
RocketMQMessageConverter rocketMQMessageConverter = new RocketMQMessageConverter();
CompositeMessageConverter messageConverter = (CompositeMessageConverter)rocketMQMessageConverter.getMessageConverter();
messageConverter.getConverters().add(0, protobufMessageConverter);
return rocketMQMessageConverter;
}
but an exception occured when consumer the message:
Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class [B (java.lang.String and [B are in module java.base of loader 'bootstrap')
at org.springframework.messaging.converter.ProtobufMessageConverter.convertFromInternal(ProtobufMessageConverter.java:147) ~[spring-messaging-5.2.8.RELEASE.jar:5.2.8.RELEASE]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant