GitHub user panxd98 edited a discussion: RocketMQ5 Proxy 将消息写入remotingCommand
我现在在开发一个Proxy的功能,需要对消费消息请求的response中的消息进行修改。
其中将response转为msgList可以用这个方法:
```
List<MessageExt>
msgList=MessageDecoder.decodesBatch(ByteBuffer.wrap(response.geteBody()),true,true,true);
```
但是要把改好后的MessageExt转回byte数组就有问题,我用了这个方法:
```
ByteBuffer byteBuffer2 = ByteBuffer.allocate(bytelen);
for (MessageExt msg : msgList){
byte[] msgByte=MessageDecoder.encode(msg,true);
byteBuffer2.put(msgByte);
}
response.setBody(byteBuffer2.array());
```
我确定ByteBuffer2的byte数组长度没有问题,但是这样做了之后我发现消费者只会消费到这一批中的第一条消息,我想知道正确的将消息写入response的方法应该是怎样的,谢谢。
GitHub link: https://github.com/apache/rocketmq/discussions/8144
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]