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 2019/05/27 05:55:51 UTC

[GitHub] [pulsar] zymap commented on a change in pull request #4348: Support max message size for cpp and go client

zymap commented on a change in pull request #4348: Support max message size for cpp and go client
URL: https://github.com/apache/pulsar/pull/4348#discussion_r287654593
 
 

 ##########
 File path: pulsar-client-cpp/lib/BatchMessageContainer.cc
 ##########
 @@ -102,12 +102,17 @@ void BatchMessageContainer::sendMessage(FlushCallback flushCallback) {
     producer_.encryptMessage(impl_->metadata, impl_->payload, encryptedPayload);
     impl_->payload = encryptedPayload;
 
-    if (impl_->payload.readableBytes() > Commands::MaxMessageSize) {
-        // At this point the compressed batch is above the overall MaxMessageSize. There
-        // can only 1 single message in the batch at this point.
-        batchMessageCallBack(ResultMessageTooBig, messagesContainerListPtr_, nullptr);
-        clear();
-        return;
+    ClientConnectionPtr cnx = producer_.getCnx().lock();
+    if (cnx) {
+        if (impl_->payload.readableBytes() > cnx->getMaxMessageSize()) {
+            // At this point the compressed batch is above the overall MaxMessageSize. There
+            // can only 1 single message in the batch at this point.
+            batchMessageCallBack(ResultMessageTooBig, messagesContainerListPtr_, nullptr);
+            clear();
+            return;
+        }
+    } else {
+        LOG_DEBUG("Connection not ready for batch message container.")
     }
 
 Review comment:
   ```
   if (cnx) {
           if (impl_->payload.readableBytes() > cnx->getMaxMessageSize()) {
               // At this point the compressed batch is above the overall MaxMessageSize. There
               // can only 1 single message in the batch at this point.
               batchMessageCallBack(ResultMessageTooBig, messagesContainerListPtr_, nullptr);
               clear();
               return;
           }
           Message msg;
           msg.impl_ = impl_;
   
           // bind keeps a copy of the parameters
           SendCallback callback = std::bind(&BatchMessageContainer::batchMessageCallBack, std::placeholders::_1,
                                             messagesContainerListPtr_, flushCallback);
   
           producer_.sendMessage(msg, callback);
           clear();
       } else {
           LOG_DEBUG("Connection not ready for batch message container.")
           batchMessageCallBack(ResultNotConnected, messagesContainerListPtr_, nullptr);
           clear();
       }
   ```

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


With regards,
Apache Git Services