Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CC4FB200B5A for ; Thu, 4 Aug 2016 23:26:46 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id CACF9160AAB; Thu, 4 Aug 2016 21:26:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1AF5C160A6A for ; Thu, 4 Aug 2016 23:26:45 +0200 (CEST) Received: (qmail 41767 invoked by uid 500); 4 Aug 2016 21:26:45 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 41758 invoked by uid 99); 4 Aug 2016 21:26:45 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Aug 2016 21:26:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 12E74E0A7D; Thu, 4 Aug 2016 21:26:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tabish@apache.org To: commits@qpid.apache.org Message-Id: <49c18c4c21e84e50a6383d0406c77bc6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: qpid-jms git commit: QPIDJMS-198 Unblock sends on remote sender link close. Date: Thu, 4 Aug 2016 21:26:45 +0000 (UTC) archived-at: Thu, 04 Aug 2016 21:26:47 -0000 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 Authored: Thu Aug 4 17:26:34 2016 -0400 Committer: Timothy Bish 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