qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject qpid-jms git commit: QPIDJMS-198 Unblock sends on remote sender link close.
Date Thu, 04 Aug 2016 21:26:45 GMT
Repository: qpid-jms
Updated Branches:
  refs/heads/master 9565185b0 -> 9a2bf6bd9


QPIDJMS-198 Unblock sends on remote sender link close.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/9a2bf6bd
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/9a2bf6bd
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/9a2bf6bd

Branch: refs/heads/master
Commit: 9a2bf6bd9623bf43b1d8007e79a297063ccaf948
Parents: 9565185
Author: Timothy Bish <tabish121@gmail.com>
Authored: Thu Aug 4 17:26:34 2016 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Thu Aug 4 17:26:34 2016 -0400

----------------------------------------------------------------------
 .../jms/provider/amqp/AmqpFixedProducer.java    | 13 +++++++
 .../integration/ProducerIntegrationTest.java    | 39 ++++++++++++++++++++
 2 files changed, 52 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/9a2bf6bd/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
index 48e9d72..8bd543e 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
@@ -328,6 +328,19 @@ public class AmqpFixedProducer extends AmqpProducer {
         }
 
         sent.clear();
+
+        for (InFlightSend blockedSend : blocked) {
+            try {
+                AsyncResult request = blockedSend.request;
+                if (request != null && !request.isComplete()) {
+                    request.onFailure(ex);
+                }
+            } catch (Exception e) {
+                LOG.debug("Caught exception when failing blocked send during remote producer
closure: {}", blockedSend, e);
+            }
+        }
+
+        blocked.clear();
     }
 
     //----- Class used to manage held sends ----------------------------------//

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/9a2bf6bd/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
index 699858a..274df16 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/ProducerIntegrationTest.java
@@ -1006,6 +1006,45 @@ public class ProducerIntegrationTest extends QpidJmsTestCase {
     }
 
     @Test(timeout = 20000)
+    public void testRemotelyCloseProducerWithSendWaitingForCredit() throws Exception {
+        final String BREAD_CRUMB = "ErrorMessageBreadCrumb";
+
+        try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
+            Connection connection = testFixture.establishConnecton(testPeer);
+
+            testPeer.expectBegin();
+            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+            // Expect producer creation, give it credit.
+            testPeer.expectSenderAttachWithoutGrantingCredit();
+
+            String text = "myMessage";
+
+            // Producer has no credit so the send should block waiting for it.
+            testPeer.remotelyDetachLastOpenedLinkOnLastOpenedSession(true, true, AmqpError.RESOURCE_LIMIT_EXCEEDED,
BREAD_CRUMB);
+            testPeer.expectClose();
+
+            Queue queue = session.createQueue("myQueue");
+            final MessageProducer producer = session.createProducer(queue);
+
+            Message message = session.createTextMessage(text);
+
+            try {
+                producer.send(message);
+                fail("Expected exception to be thrown");
+            } catch (JMSException jmse) {
+                // Expected
+                assertNotNull("Expected exception to have a message", jmse.getMessage());
+                assertTrue("Expected breadcrumb to be present in message", jmse.getMessage().contains(BREAD_CRUMB));
+            }
+
+            connection.close();
+
+            testPeer.waitForAllHandlersToComplete(3000);
+        }
+    }
+
+    @Test(timeout = 20000)
     public void testRemotelyCloseConnectionDuringSyncSend() throws Exception {
         final String BREAD_CRUMB = "ErrorMessageBreadCrumb";
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message