You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/05/27 03:37:00 UTC

[GitHub] [pulsar-client-go] jinfengnarvar commented on a change in pull request #263: [Issue 240] Add check for max message size

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



##########
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:
       Curious why not use `.WithError(errMessageTooLarge).Error()`?

##########
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:
       I'm even newer to the project :) @wolfstudy ?




----------------------------------------------------------------
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:
users@infra.apache.org