Gleiphir2769 commented on code in PR #805:
URL: https://github.com/apache/pulsar-client-go/pull/805#discussion_r974260113


##########
pulsar/producer_partition.go:
##########
@@ -560,49 +728,60 @@ func (p *partitionProducer) internalSend(request 
*sendRequest) {
                smm.Properties = internal.ConvertFromStringMap(msg.Properties)
        }
 
+       var sequenceID uint64
        if msg.SequenceID != nil {
-               sequenceID := uint64(*msg.SequenceID)
-               smm.SequenceId = proto.Uint64(sequenceID)
+               sequenceID = uint64(*msg.SequenceID)
+       } else {
+               sequenceID = internal.GetAndAdd(p.sequenceIDGenerator, 1)
        }
 
-       if !sendAsBatch {
-               p.internalFlushCurrentBatch()
-       }
+       smm.SequenceId = proto.Uint64(sequenceID)
 
-       if msg.DisableReplication {
-               msg.ReplicationClusters = []string{"__local__"}
-       }
-       multiSchemaEnabled := !p.options.DisableMultiSchema
-       added := p.batchBuilder.Add(smm, p.sequenceIDGenerator, payload, 
request,
-               msg.ReplicationClusters, deliverAt, schemaVersion, 
multiSchemaEnabled)
-       if !added {
-               // The current batch is full.. flush it and retry
+       return
+}
 
-               p.internalFlushCurrentBatch()
+func (p *partitionProducer) internalSingleSend(mm *pb.MessageMetadata,
+       compressedPayload []byte,
+       request *sendRequest,
+       maxMessageSize uint32) {
+       msg := request.msg
 
-               // after flushing try again to add the current payload
-               if ok := p.batchBuilder.Add(smm, p.sequenceIDGenerator, 
payload, request,
-                       msg.ReplicationClusters, deliverAt, schemaVersion, 
multiSchemaEnabled); !ok {
-                       p.publishSemaphore.Release()
-                       request.callback(nil, request.msg, errFailAddToBatch)
-                       p.log.WithField("size", len(payload)).
-                               WithField("properties", msg.Properties).
-                               Error("unable to add message to batch")
-                       return
-               }
-       }
+       payloadBuf := internal.NewBuffer(len(compressedPayload))
+       payloadBuf.Write(compressedPayload)
 
-       if !sendAsBatch || request.flushImmediately {
+       buffer := p.GetBuffer()
+       if buffer == nil {
+               buffer = internal.NewBuffer(int(payloadBuf.ReadableBytes() * 3 
/ 2))
+       }
 
-               p.internalFlushCurrentBatch()
+       sid := *mm.SequenceId
 
+       if err := internal.SingleSend(
+               buffer,
+               p.producerID,
+               sid,
+               mm,
+               payloadBuf,
+               p.encryptor,
+               maxMessageSize,
+       ); err != nil {
+               request.callback(nil, request.msg, err)

Review Comment:
   Same as above.



-- 
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