leader318 opened a new pull request, #845:
URL: https://github.com/apache/rocketmq-clients/pull/845

   当客户发发送一个数据量大的消息体时,由于进行了gzip 压缩,golang 版本的代码,消费数据时,原先GZIPDecode 
方法有问题,故新增了一个BytesGzipDecode 方法,测试无问题,可以正常消费。
   
   
   旧函数:
   `
   func GZIPDecode(in []byte) ([]byte, error) {
        reader, err := gzip.NewReader(bytes.NewReader(in))
        if err != nil {
                var out []byte
                return out, err
        }
        defer reader.Close()
        return ioutil.ReadAll(reader)
   }
   
   `
   
   新增函数:
   
   `
   func BytesGzipDecode(src []byte) ([]byte, error) {
        // Create a zlib reader
        byteArrayInputStream := bytes.NewReader(src)
        inflatesInputStream, err := zlib.NewReader(byteArrayInputStream)
        if err != nil {
                return nil, err
        }
        defer inflatesInputStream.Close()
        // Create a buffer to store decompressed data
        var byteArrayOutputStream bytes.Buffer
        _, err = io.Copy(&byteArrayOutputStream, inflatesInputStream)
        if err != nil {
                return nil, err
        }
        return byteArrayOutputStream.Bytes(), nil
   }
   `


-- 
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-unsubscr...@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to