From 318778954db744213d3a72d06cb91108542f1804 Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Fri, 10 Feb 2017 11:27:54 +0000 Subject: [PATCH 1/2] ENTMQBR-522 - dont ack on separately settled deliveries https://issues.jboss.org/browse/ENTMQBR-522 --- .../proton/ProtonServerSenderContext.java | 5 ++++ .../transport/amqp/client/AmqpMessage.java | 4 +++ .../integration/amqp/AmqpSendReceiveTest.java | 26 +++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java index 938c6cacd2..41c996aaf3 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java @@ -507,6 +507,11 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr } } } else if (remoteState instanceof Accepted) { + //this can happen in the twice ack mode, that is the receiver accepts and settles separately + //acking again would show an exception but would have no negative effect but best to handle anyway. + if (delivery.isSettled()) { + return; + } // we have to individual ack as we can't guarantee we will get the delivery updates // (including acks) in order // from dealer, a perf hit but a must diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpMessage.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpMessage.java index bd893773a1..0c4250db52 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpMessage.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpMessage.java @@ -627,4 +627,8 @@ public class AmqpMessage { message.setProperties(new Properties()); } } + + public void settle() { + delivery.settle(); + } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java index b9d550440e..dd98defc46 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java @@ -74,6 +74,32 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { connection.close(); } + @Test(timeout = 60000) + public void testAcceptWithoutSettling() throws Exception { + AmqpClient client = createAmqpClient(); + AmqpConnection connection = addConnection(client.connect()); + AmqpSession session = connection.createSession(); + + AmqpReceiver receiver = session.createReceiver(getTestName()); + + sendMessages(getTestName(), 10); + + for (int i = 0; i < 10; i++) { + receiver.flow(1); + AmqpMessage receive = receiver.receive(); + receive.accept(false); + receive.settle(); + } + + receiver.close(); + connection.close(); + + Queue queue = getProxyToQueue(getTestName()); + assertNotNull(queue); + assertEquals(0, queue.getMessageCount()); + } + + @Test(timeout = 60000) public void testCreateQueueReceiverWithJMSSelector() throws Exception { AmqpClient client = createAmqpClient(); From c3436a36a0c06ecd3410a8a090c60e2c5d88d14e Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Fri, 10 Feb 2017 11:44:05 +0000 Subject: [PATCH 2/2] NO-JIRA: fix typo on the cli ./artemis help was returning "exp" twice on the --- .../src/main/java/org/apache/activemq/artemis/cli/Artemis.java | 2 +- docs/user-manual/en/tools.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java index 843b6f1a18..2821a3e22c 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java @@ -159,7 +159,7 @@ public class Artemis { withDefaultCommand(HelpAddress.class).withCommands(CreateAddress.class, DeleteAddress.class, UpdateAddress.class, ShowAddress.class); if (instance != null) { - builder.withGroup("data").withDescription("data tools group (print|exp|imp|exp|encode|decode|compact) (example ./artemis data print)"). + builder.withGroup("data").withDescription("data tools group (print|imp|exp|encode|decode|compact) (example ./artemis data print)"). withDefaultCommand(HelpData.class).withCommands(PrintData.class, XmlDataExporter.class, XmlDataImporter.class, DecodeJournal.class, EncodeJournal.class, CompactJournal.class); builder.withGroup("user").withDescription("default file-based user management (add|rm|list|reset) (example ./artemis user list)"). withDefaultCommand(HelpUser.class).withCommands(ListUser.class, AddUser.class, RemoveUser.class, ResetUser.class); diff --git a/docs/user-manual/en/tools.md b/docs/user-manual/en/tools.md index b36e13223c..8ea57ea392 100644 --- a/docs/user-manual/en/tools.md +++ b/docs/user-manual/en/tools.md @@ -49,7 +49,7 @@ For a full list of data tools commands available use: ``` NAME artemis data - data tools group - (print|exp|imp|exp|encode|decode|compact) (example ./artemis data print) + (print|imp|exp|encode|decode|compact) (example ./artemis data print) SYNOPSIS artemis data