keithnull commented on a change in pull request #263:
URL: https://github.com/apache/pulsar-client-go/pull/263#discussion_r430450652



##########
File path: pulsar/producer_partition.go
##########
@@ -236,6 +239,16 @@ func (p *partitionProducer) internalSend(request 
*sendRequest) {
 
        msg := request.msg
 
+       // if msg is too large
+       if len(msg.Payload) > int(p.cnx.GetMaxMessageSize()) {
+               p.publishSemaphore.Release()
+               request.callback(nil, request.msg, errMessageTooLarge)
+               p.log.WithField("size", len(msg.Payload)).
+                       WithField("properties", msg.Properties).
+                       Error("message size exceeds MaxMessageSize")

Review comment:
       Oh, thanks for pointing this out~ 
   
   As I'm new to this project, when I was writing these lines, I mainly 
referred to other error handling lines in the same function, which use 
`.Error("xxx")` rather than `.WithError()`. 
   
   But I think your idea is better, so maybe we need to rewrite other error 
handling lines as well?

##########
File path: pulsar/producer_partition.go
##########
@@ -236,6 +239,16 @@ func (p *partitionProducer) internalSend(request 
*sendRequest) {
 
        msg := request.msg
 
+       // if msg is too large
+       if len(msg.Payload) > int(p.cnx.GetMaxMessageSize()) {
+               p.publishSemaphore.Release()
+               request.callback(nil, request.msg, errMessageTooLarge)
+               p.log.WithField("size", len(msg.Payload)).
+                       WithField("properties", msg.Properties).
+                       Error("message size exceeds MaxMessageSize")

Review comment:
       Oh, thanks for pointing this out~ 
   
   As I'm new to this project, when I was writing these lines, I mainly 
referred to other error handling lines in the same function, which use 
`.Error("xxx")` rather than `.WithError()`. So I wrote it this way for 
consistency.
   
   But I think your idea is better, so maybe we need to rewrite other error 
handling lines as well?




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

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


Reply via email to