[1/2] activemq-artemis git commit: ARTEMIS-1535 - settle delivery in same lock as sending the disposition

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[1/2] activemq-artemis git commit: ARTEMIS-1535 - settle delivery in same lock as sending the disposition

clebertsuconic-2
Repository: activemq-artemis
Updated Branches:
  refs/heads/master e129fc795 -> 7c702245f


ARTEMIS-1535 - settle delivery in same lock as sending the disposition

https://issues.apache.org/jira/browse/ARTEMIS-1535


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/34a912b6
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/34a912b6
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/34a912b6

Branch: refs/heads/master
Commit: 34a912b644d97c4c6c420095a0df587007355512
Parents: e129fc7
Author: Andy Taylor <[hidden email]>
Authored: Tue Dec 5 12:12:54 2017 +0000
Committer: Clebert Suconic <[hidden email]>
Committed: Tue Dec 5 22:54:08 2017 -0500

----------------------------------------------------------------------
 .../transaction/ProtonTransactionHandler.java   | 48 ++++++++++----------
 1 file changed, 23 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/34a912b6/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/transaction/ProtonTransactionHandler.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/transaction/ProtonTransactionHandler.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/transaction/ProtonTransactionHandler.java
index bf2e575..28573e0 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/transaction/ProtonTransactionHandler.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/transaction/ProtonTransactionHandler.java
@@ -101,17 +101,29 @@ public class ProtonTransactionHandler implements ProtonDeliveryHandler {
          }
 
          Object action = ((AmqpValue) msg.getBody()).getValue();
-
          if (action instanceof Declare) {
             Binary txID = sessionSPI.newTransaction();
             Declared declared = new Declared();
             declared.setTxnId(txID);
-            connection.lock();
-            try {
-               delivery.disposition(declared);
-            } finally {
-               connection.unlock();
-            }
+            IOCallback ioAction = new IOCallback() {
+               @Override
+               public void done() {
+                  connection.lock();
+                  try {
+                     delivery.settle();
+                     delivery.disposition(declared);
+                  } finally {
+                     connection.unlock();
+                     connection.flush();
+                  }
+               }
+
+               @Override
+               public void onError(int errorCode, String errorMessage) {
+
+               }
+            };
+            sessionSPI.afterIO(ioAction);
          } else if (action instanceof Discharge) {
             Discharge discharge = (Discharge) action;
 
@@ -124,9 +136,11 @@ public class ProtonTransactionHandler implements ProtonDeliveryHandler {
                public void done() {
                   connection.lock();
                   try {
+                     delivery.settle();
                      delivery.disposition(new Accepted());
                   } finally {
                      connection.unlock();
+                     connection.flush();
                   }
                }
 
@@ -148,6 +162,7 @@ public class ProtonTransactionHandler implements ProtonDeliveryHandler {
          log.warn(amqpE.getMessage(), amqpE);
          connection.lock();
          try {
+            delivery.settle();
             delivery.disposition(createRejected(amqpE.getAmqpError(), amqpE.getMessage()));
          } finally {
             connection.unlock();
@@ -157,29 +172,12 @@ public class ProtonTransactionHandler implements ProtonDeliveryHandler {
          log.warn(e.getMessage(), e);
          connection.lock();
          try {
+            delivery.settle();
             delivery.disposition(createRejected(Symbol.getSymbol("failed"), e.getMessage()));
          } finally {
             connection.unlock();
          }
          connection.flush();
-      } finally {
-         sessionSPI.afterIO(new IOCallback() {
-            @Override
-            public void done() {
-               connection.lock();
-               try {
-                  delivery.settle();
-               } finally {
-                  connection.unlock();
-               }
-               connection.flush();
-            }
-
-            @Override
-            public void onError(int errorCode, String errorMessage) {
-
-            }
-         });
       }
    }
 

Reply | Threaded
Open this post in threaded view
|

[2/2] activemq-artemis git commit: This closes #1687

clebertsuconic-2
This closes #1687


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/7c702245
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/7c702245
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/7c702245

Branch: refs/heads/master
Commit: 7c702245f37a87a0cd632529a336265e9f1824c8
Parents: e129fc7 34a912b
Author: Clebert Suconic <[hidden email]>
Authored: Tue Dec 5 22:54:09 2017 -0500
Committer: Clebert Suconic <[hidden email]>
Committed: Tue Dec 5 22:54:09 2017 -0500

----------------------------------------------------------------------
 .../transaction/ProtonTransactionHandler.java   | 48 ++++++++++----------
 1 file changed, 23 insertions(+), 25 deletions(-)
----------------------------------------------------------------------