clebertsuconic commented on code in PR #4240:
URL: https://github.com/apache/activemq-artemis/pull/4240#discussion_r985901312


##########
artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java:
##########
@@ -558,6 +564,21 @@ public void physicalSend(Command command) throws 
IOException {
 
    }
 
+   private void chunkSend(final ByteSequence bytes, final int bufferSize, 
final int maxPacketSize) {
+      if (logger.isTraceEnabled()) {
+         logger.trace("Sending a big packet sized as {} with smaller packets 
of {}", bufferSize, maxPacketSize);
+      }
+      for (int posBuffer = 0; posBuffer < bufferSize; posBuffer += 
maxPacketSize) {
+         int chunkSize = Math.min(bufferSize - posBuffer, maxPacketSize);
+         if (logger.isTraceEnabled()) {
+            logger.trace("Sending a partial packet of {} bytes, starting at 
{}", chunkSize, posBuffer);
+         }
+         final ActiveMQBuffer buffer = 
transportConnection.createTransportBuffer(chunkSize);

Review Comment:
   I'm splitting a big buffer chunk into smaller buffers
   
   
   so, if you have a 200MB message, I'm calling multiple writes instead of just 
one mega-write



##########
artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java:
##########
@@ -558,6 +564,21 @@ public void physicalSend(Command command) throws 
IOException {
 
    }
 
+   private void chunkSend(final ByteSequence bytes, final int bufferSize, 
final int maxPacketSize) {
+      if (logger.isTraceEnabled()) {
+         logger.trace("Sending a big packet sized as {} with smaller packets 
of {}", bufferSize, maxPacketSize);
+      }
+      for (int posBuffer = 0; posBuffer < bufferSize; posBuffer += 
maxPacketSize) {
+         int chunkSize = Math.min(bufferSize - posBuffer, maxPacketSize);
+         if (logger.isTraceEnabled()) {
+            logger.trace("Sending a partial packet of {} bytes, starting at 
{}", chunkSize, posBuffer);
+         }
+         final ActiveMQBuffer buffer = 
transportConnection.createTransportBuffer(chunkSize);

Review Comment:
   ah... no.. it can't be reused.... netty will be holding it down the 
pipeline...



##########
artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java:
##########
@@ -558,6 +564,21 @@ public void physicalSend(Command command) throws 
IOException {
 
    }
 
+   private void chunkSend(final ByteSequence bytes, final int bufferSize, 
final int maxPacketSize) {
+      if (logger.isTraceEnabled()) {
+         logger.trace("Sending a big packet sized as {} with smaller packets 
of {}", bufferSize, maxPacketSize);
+      }
+      for (int posBuffer = 0; posBuffer < bufferSize; posBuffer += 
maxPacketSize) {
+         int chunkSize = Math.min(bufferSize - posBuffer, maxPacketSize);
+         if (logger.isTraceEnabled()) {
+            logger.trace("Sending a partial packet of {} bytes, starting at 
{}", chunkSize, posBuffer);
+         }
+         final ActiveMQBuffer buffer = 
transportConnection.createTransportBuffer(chunkSize);

Review Comment:
   although I'm calling flush... but I would prefer to keep it through the pool 
like it's always done.
   
   
   if I wanted to reuse it.. I would have to increase the the counter with a 
refUp here.. I would prefer to not deal with that.



##########
artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java:
##########
@@ -558,6 +564,21 @@ public void physicalSend(Command command) throws 
IOException {
 
    }
 
+   private void chunkSend(final ByteSequence bytes, final int bufferSize, 
final int maxPacketSize) {
+      if (logger.isTraceEnabled()) {
+         logger.trace("Sending a big packet sized as {} with smaller packets 
of {}", bufferSize, maxPacketSize);
+      }
+      for (int posBuffer = 0; posBuffer < bufferSize; posBuffer += 
maxPacketSize) {
+         int chunkSize = Math.min(bufferSize - posBuffer, maxPacketSize);
+         if (logger.isTraceEnabled()) {
+            logger.trace("Sending a partial packet of {} bytes, starting at 
{}", chunkSize, posBuffer);
+         }
+         final ActiveMQBuffer buffer = 
transportConnection.createTransportBuffer(chunkSize);

Review Comment:
   I tried to make a change with the same buffer, but I got some refCounts 
issues... I would prefer to keep the way it is now.



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