Open huangwjwork opened 1 year ago
我们也碰到这个问题了,请问下这个问题修复了没?
I also met this problem, and even after updated my zlib version, this problem still remains.
我在测试C++接口时也遇到了同样的问题,在接口中增加日志排查后发现是调用接口的用法存在问题: C++的send接口时传递的MQMessage对象的引用,如果上一次的MQMessage的大小超过设置的压缩限制,就会启动压缩,那么在send接口返回后,MQMessage对象也会被修改(设置压缩标记、Body也被替换成压缩后的内容)。 如果下一次调用send接口时,复用上一次的MQMessage对象,只修改Body,就会出现Body内容和压缩标记不一致的现象,导致消息(内容没压缩但标记着已经压缩)传递给消费者后出现无法解压的错误。
错误代码示例:
rocketmq::MQMessage msg(topic, tag, "");
for (unsigned i = 0; i < send_num; ++i) {
try {
char *body = new char[send_size];
msg.setBody(body, send_size); // msg被重新设置内容,但是标记不变
rocketmq::SendResult sendResult = producer->send(msg);
printf("msg size[%d]\n", msg.getBody().length());
delete []body;
} catch (rocketmq::MQException &e) {
printf("send error[%d][%s]", e.GetError(), e.what());
return -1;
}
I use python client (https://github.com/apache/rocketmq-client-python) to call rocketmq-client-cpp ,and when I consumer some messages,I get that:
terminate called ater throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector>'
what(): zlib error
my env:
os rhel7.9 kernle:3.10.0-1160 clinet: rocketmq-client-cpp-2.1.0 rocketmq-client-cpp-2.0.0 (Both versions have this issue)