You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/10/18 07:11:11 UTC
[GitHub] [rocketmq-clients] aaron-ai commented on issue #262: Could MessageView provide a graceful method to get message body
aaron-ai commented on issue #262:
URL: https://github.com/apache/rocketmq-clients/issues/262#issuecomment-1281913560
The underlying byte array of `bytebuffer` is readonly, which means you could not get it directly, so copy it from `bytebuffer` rather than get it directly if you need `byte[]`.
```java
byte[] bytes = new byte[body.remaining()];
body.get(bytes);
```
or you could easily get `String` type according to your type.
```java
// Replace by your charset
final String body = StandardCharsets.UTF_8.decode(messageView.getBody()).toString();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org