activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [3/3] activemq-artemis git commit: ARTEMIS-1090 - Message not expired if absolute expiry time is 0 and ttl is set
Date Mon, 03 Apr 2017 13:28:17 GMT
ARTEMIS-1090 - Message not expired if absolute expiry time is 0 and ttl is set

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


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

Branch: refs/heads/master
Commit: 5529bf150a7b3ac2e1cae7a883ad78ce27f0fe30
Parents: 57bae51
Author: Andy Taylor <andy.tayls67@gmail.com>
Authored: Mon Apr 3 08:22:51 2017 +0100
Committer: Martyn Taylor <mtaylor@redhat.com>
Committed: Mon Apr 3 14:28:02 2017 +0100

----------------------------------------------------------------------
 .../protocol/amqp/broker/AMQPMessage.java       |  2 +-
 .../amqp/AmqpExpiredMessageTest.java            | 35 ++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5529bf15/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
index d2a91df..affe49a 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
@@ -402,7 +402,7 @@ public class AMQPMessage extends RefCountMessage {
          if (section instanceof Properties) {
             _properties = (Properties) section;
 
-            if (_properties.getAbsoluteExpiryTime() != null) {
+            if (_properties.getAbsoluteExpiryTime() != null && _properties.getAbsoluteExpiryTime().getTime()
> 0) {
                this.expiration = _properties.getAbsoluteExpiryTime().getTime();
             }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5529bf15/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpExpiredMessageTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpExpiredMessageTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpExpiredMessageTest.java
index c075be1..047d88d 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpExpiredMessageTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpExpiredMessageTest.java
@@ -125,6 +125,41 @@ public class AmqpExpiredMessageTest extends AmqpClientTestSupport {
    }
 
    @Test(timeout = 60000)
+   public void testSendMessageThatIsExpiredUsingTTLWhenAbsoluteIsZero() throws Exception
{
+      AmqpClient client = createAmqpClient();
+      AmqpConnection connection = addConnection(client.connect());
+      AmqpSession session = connection.createSession();
+
+      AmqpSender sender = session.createSender(getTestName());
+
+      // Get the Queue View early to avoid racing the delivery.
+      final Queue queueView = getProxyToQueue(getTestName());
+      assertNotNull(queueView);
+
+      AmqpMessage message = new AmqpMessage();
+      message.setAbsoluteExpiryTime(0);
+      // AET should override any TTL set
+      message.setTimeToLive(1000);
+      message.setText("Test-Message");
+      sender.send(message);
+      sender.close();
+
+      assertEquals(1, queueView.getMessageCount());
+
+      Thread.sleep(1000);
+
+      // Now try and get the message
+      AmqpReceiver receiver = session.createReceiver(getTestName());
+      receiver.flow(1);
+      AmqpMessage received = receiver.receive(1, TimeUnit.SECONDS);
+      assertNull(received);
+
+      assertEquals(1, queueView.getMessagesExpired());
+
+      connection.close();
+   }
+
+   @Test(timeout = 60000)
    public void testSendMessageThatIsNotExpiredUsingAbsoluteTimeWithElspsedTTL() throws Exception
{
       AmqpClient client = createAmqpClient();
       AmqpConnection connection = addConnection(client.connect());


Mime
View raw message