tabish121 commented on code in PR #4840:
URL: https://github.com/apache/activemq-artemis/pull/4840#discussion_r1514638970


##########
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonAbstractReceiver.java:
##########
@@ -320,28 +325,45 @@ public final void onMessage(Delivery delivery) throws 
ActiveMQAMQPException {
             return;
          }
 
-         final Message message = messageReader.readBytes(delivery);
+         {
+            Message completeMessage;
+            if ((completeMessage = messageReader.readBytes(delivery)) != null) 
{
+               // notice the AMQP Large Message Reader will always return false
+               // and call the onMessageComplete directly
+               // since that happens asynchronously
+               onMessageComplete(delivery, completeMessage, 
messageReader.getDeliveryAnnotations());
+            }
+         }
+      } catch (Exception e) {
+         logger.warn(e.getMessage(), e);
+         throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e);
+      }
+   }
 
-         if (message != null) {
-            // Fetch this before the close of the reader as that will clear 
any read message
-            // delivery annotations.
-            final DeliveryAnnotations deliveryAnnotations = 
messageReader.getDeliveryAnnotations();
+   public void onMessageComplete(Delivery delivery,
+                          Message message, DeliveryAnnotations 
deliveryAnnotations) {
+      connection.requireInHandler();
 
-            this.messageReader.close();
-            this.messageReader = null;
+      try {
+         final Receiver receiver = ((Receiver) delivery.getLink());

Review Comment:
   It isn't really necessary to get and cast here as the ProtonAbstractReceiver 
already owns a reference to the proton receiver in play. 



##########
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPLargeMessageWriter.java:
##########
@@ -81,33 +84,55 @@ public boolean isWriting() {
    public void close() {
       if (!closed) {
          try {
+            try {
+               if (largeBodyReader != null) {
+                  largeBodyReader.close();
+               }
+            } catch (Exception e) {
+               // if we get an error only at this point, there's nothing else 
we could do other than log.warn
+               logger.warn("{}", e.getMessage(), e);
+            }
             if (message != null) {
                message.usageDown();
             }
          } finally {
-            reset(true);
+            resetClosed();
          }
       }
    }
 
    @Override
-   public AMQPLargeMessageWriter open() {
-      if (!closed) {

Review Comment:
   Closed check should still be required here



##########
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonAbstractReceiver.java:
##########
@@ -320,28 +325,45 @@ public final void onMessage(Delivery delivery) throws 
ActiveMQAMQPException {
             return;
          }
 
-         final Message message = messageReader.readBytes(delivery);
+         {

Review Comment:
   Is there a reason for the added surrounding scope here?  Seems unneeded in 
this context



-- 
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: gitbox-unsubscr...@activemq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to