labuladong commented on issue #847:
URL: 
https://github.com/apache/pulsar-client-go/issues/847#issuecomment-1248920510

   Hi @jack-tristan, I can't reproduce your problem with pulsar version v2.6.3 
and client-go version V0.8.1. Seems that these lines of code get `false` 
result, then throw a "unable to add message to batch" error:
   
   
https://github.com/apache/pulsar-client-go/blob/ea6eccf7ddad548a1ad977a0b72a61b894e6d248/pulsar/internal/batch_builder.go#L177-L199
   
   Do you have more context information about this problem?
   
   My test code:
   
   ```golang
   package main
   
   import (
        "context"
        "github.com/apache/pulsar-client-go/pulsar"
        log "github.com/sirupsen/logrus"
        "strings"
        "time"
   )
   
   func main() {
        ProducerString(genStr(199999)) // when the string size > 132000,program 
will throw "unable to add message to batch" using pulsar-client-go version 
v0.8.0 & v0.8.1
   }
   
   // generate test string
   func genStr(size int) string {
        var builder strings.Builder
        for i := 0; i < size; i++ {
                builder.WriteString("a")
                //builder.WriteString("abcdefghi,")
        }
        return builder.String()
   }
   
   // ProducerString producer to send msg
   func ProducerString(str string) {
        client, err := pulsar.NewClient(pulsar.ClientOptions{
                URL:               "pulsar://192.168.50.117:6650",
                OperationTimeout:  30 * time.Second,
                ConnectionTimeout: 30 * time.Second,
        })
        if err != nil {
                log.Error(err)
                return
        }
        defer client.Close()
   
        producer, err := client.CreateProducer(pulsar.ProducerOptions{
                Topic:           "pt-longstr-v1",
                Schema:          pulsar.NewStringSchema(nil),
                CompressionType: pulsar.LZ4,
                DisableBatching: true,
        })
        defer producer.Close()
   
        msgID, err := producer.Send(context.Background(), 
&pulsar.ProducerMessage{
                Value: str,
        })
        if err != nil {
                log.Error(err)
        }
        log.Info("success: ", msgID)
   }
   ```
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to