[1/4] activemq-artemis git commit: ARTEMIS-1041 Using less time on timeouts

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

[1/4] activemq-artemis git commit: ARTEMIS-1041 Using less time on timeouts

clebertsuconic-2
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 2ba90ef60 -> dca124f9a


ARTEMIS-1041 Using less time on timeouts


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

Branch: refs/heads/master
Commit: 8a84b6a1a79f659103e2a3fd487a852d101a8659
Parents: 938c4ec
Author: Clebert Suconic <[hidden email]>
Authored: Wed Mar 15 19:21:44 2017 -0400
Committer: Clebert Suconic <[hidden email]>
Committed: Wed Mar 15 19:25:08 2017 -0400

----------------------------------------------------------------------
 .../artemis/tests/integration/amqp/AmqpExpiredMessageTest.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8a84b6a1/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 0a1f382..c075be1 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
@@ -52,7 +52,7 @@ public class AmqpExpiredMessageTest extends AmqpClientTestSupport {
       // Now try and get the message
       AmqpReceiver receiver = session.createReceiver(getTestName());
       receiver.flow(1);
-      AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS);
+      AmqpMessage received = receiver.receive(1, TimeUnit.SECONDS);
       assertNull(received);
 
       assertEquals(1, queueView.getMessagesExpired());
@@ -116,7 +116,7 @@ public class AmqpExpiredMessageTest extends AmqpClientTestSupport {
       // Now try and get the message
       AmqpReceiver receiver = session.createReceiver(getTestName());
       receiver.flow(1);
-      AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS);
+      AmqpMessage received = receiver.receive(1, TimeUnit.SECONDS);
       assertNull(received);
 
       assertEquals(1, queueView.getMessagesExpired());
@@ -215,7 +215,7 @@ public class AmqpExpiredMessageTest extends AmqpClientTestSupport {
       // Now try and get the message
       AmqpReceiver receiver = session.createReceiver(getTestName());
       receiver.flow(1);
-      AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS);
+      AmqpMessage received = receiver.receive(1, TimeUnit.SECONDS);
       assertNull(received);
 
       assertEquals(1, queueView.getMessagesExpired());

Reply | Threaded
Open this post in threaded view
|

[2/4] activemq-artemis git commit: ARTEMIS-1041 Apply absolute expiration time to message

clebertsuconic-2
ARTEMIS-1041 Apply absolute expiration time to message

Use the Absolute Expiration Time from the message properties and
override any value set in TTL if anything set there.

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

Branch: refs/heads/master
Commit: 938c4ec5583b63f284197aa8fbaa7d9c3ba33911
Parents: 2ba90ef
Author: Timothy Bish <[hidden email]>
Authored: Wed Mar 15 16:25:40 2017 -0400
Committer: Clebert Suconic <[hidden email]>
Committed: Wed Mar 15 19:25:08 2017 -0400

----------------------------------------------------------------------
 .../protocol/amqp/broker/AMQPMessage.java       |  13 +-
 .../transport/amqp/client/AmqpMessage.java      |  61 ++++-
 .../amqp/AmqpExpiredMessageTest.java            | 225 +++++++++++++++++++
 3 files changed, 290 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/938c4ec5/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 a158799..56ac1f5 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
@@ -23,9 +23,6 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.PooledByteBufAllocator;
-import io.netty.buffer.Unpooled;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
 import org.apache.activemq.artemis.api.core.ICoreMessage;
@@ -52,6 +49,10 @@ import org.apache.qpid.proton.codec.WritableBuffer;
 import org.apache.qpid.proton.message.Message;
 import org.apache.qpid.proton.message.impl.MessageImpl;
 
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.PooledByteBufAllocator;
+import io.netty.buffer.Unpooled;
+
 // see https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format
 public class AMQPMessage extends RefCountMessage {
 
@@ -320,7 +321,6 @@ public class AMQPMessage extends RefCountMessage {
             } else {
                section = null;
             }
-
          }
          if (section instanceof MessageAnnotations) {
             _messageAnnotations = (MessageAnnotations) section;
@@ -330,11 +330,14 @@ public class AMQPMessage extends RefCountMessage {
             } else {
                section = null;
             }
-
          }
          if (section instanceof Properties) {
             _properties = (Properties) section;
 
+            if (_properties.getAbsoluteExpiryTime() != null) {
+               this.expiration = _properties.getAbsoluteExpiryTime().getTime();
+            }
+
             if (buffer.hasRemaining()) {
                section = (Section) decoder.readObject();
             } else {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/938c4ec5/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/AmqpMessage.java
----------------------------------------------------------------------
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 0c4250d..8599fa9 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
@@ -426,12 +426,65 @@ public class AmqpMessage {
    }
 
    /**
-    * Sets the priority header on the outgoing message.
+    * Gets the priority header on the message.
     */
    public short getPriority() {
       return getWrappedMessage().getPriority();
    }
 
+   /**
+    * Sets the ttl header on the outgoing message.
+    *
+    * @param timeToLive the ttl value to set.
+    */
+   public void setTimeToLive(long timeToLive) {
+      checkReadOnly();
+      lazyCreateHeader();
+      getWrappedMessage().setTtl(timeToLive);
+   }
+
+   /**
+    * Sets the ttl header on the outgoing message.
+    */
+   public long getTimeToLive() {
+      return getWrappedMessage().getTtl();
+   }
+
+   /**
+    * Sets the absolute expiration time property on the message.
+    *
+    * @param absoluteExpiryTime the expiration time value to set.
+    */
+   public void setAbsoluteExpiryTime(long absoluteExpiryTime) {
+      checkReadOnly();
+      lazyCreateProperties();
+      getWrappedMessage().setExpiryTime(absoluteExpiryTime);
+   }
+
+   /**
+    * Gets the absolute expiration time property on the message.
+    */
+   public long getAbsoluteExpiryTime() {
+      return getWrappedMessage().getExpiryTime();
+   }
+
+   /**
+    * Sets the creation time property on the message.
+    *
+    * @param absoluteExpiryTime the expiration time value to set.
+    */
+   public void setCreationTime(long creationTime) {
+      checkReadOnly();
+      lazyCreateProperties();
+      getWrappedMessage().setCreationTime(creationTime);
+   }
+
+   /**
+    * Gets the absolute expiration time property on the message.
+    */
+   public long getCreationTime() {
+      return getWrappedMessage().getCreationTime();
+   }
 
    /**
     * Sets a given application property on an outbound message.
@@ -597,21 +650,21 @@ public class AmqpMessage {
 
    private void lazyCreateMessageAnnotations() {
       if (messageAnnotationsMap == null) {
-         messageAnnotationsMap = new HashMap<Symbol, Object>();
+         messageAnnotationsMap = new HashMap<>();
          message.setMessageAnnotations(new MessageAnnotations(messageAnnotationsMap));
       }
    }
 
    private void lazyCreateDeliveryAnnotations() {
       if (deliveryAnnotationsMap == null) {
-         deliveryAnnotationsMap = new HashMap<Symbol, Object>();
+         deliveryAnnotationsMap = new HashMap<>();
          message.setDeliveryAnnotations(new DeliveryAnnotations(deliveryAnnotationsMap));
       }
    }
 
    private void lazyCreateApplicationProperties() {
       if (applicationPropertiesMap == null) {
-         applicationPropertiesMap = new HashMap<String, Object>();
+         applicationPropertiesMap = new HashMap<>();
          message.setApplicationProperties(new ApplicationProperties(applicationPropertiesMap));
       }
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/938c4ec5/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
new file mode 100644
index 0000000..0a1f382
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpExpiredMessageTest.java
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.tests.integration.amqp;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.transport.amqp.client.AmqpClient;
+import org.apache.activemq.transport.amqp.client.AmqpConnection;
+import org.apache.activemq.transport.amqp.client.AmqpMessage;
+import org.apache.activemq.transport.amqp.client.AmqpReceiver;
+import org.apache.activemq.transport.amqp.client.AmqpSender;
+import org.apache.activemq.transport.amqp.client.AmqpSession;
+import org.junit.Test;
+
+public class AmqpExpiredMessageTest extends AmqpClientTestSupport {
+
+   @Test(timeout = 60000)
+   public void testSendMessageThatIsAlreadyExpiredUsingAbsoluteTime() 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(System.currentTimeMillis() - 5000);
+      message.setText("Test-Message");
+      sender.send(message);
+      sender.close();
+
+      assertEquals(1, queueView.getMessageCount());
+
+      // Now try and get the message
+      AmqpReceiver receiver = session.createReceiver(getTestName());
+      receiver.flow(1);
+      AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS);
+      assertNull(received);
+
+      assertEquals(1, queueView.getMessagesExpired());
+
+      connection.close();
+   }
+
+   @Test(timeout = 60000)
+   public void testSendMessageThatIsNotExpiredUsingAbsoluteTime() 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(System.currentTimeMillis() + 5000);
+      message.setText("Test-Message");
+      sender.send(message);
+      sender.close();
+
+      assertEquals(1, queueView.getMessageCount());
+
+      // Now try and get the message
+      AmqpReceiver receiver = session.createReceiver(getTestName());
+      receiver.flow(1);
+      AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS);
+      assertNotNull(received);
+
+      assertEquals(0, queueView.getMessagesExpired());
+
+      connection.close();
+   }
+
+   @Test(timeout = 60000)
+   public void testSendMessageThatIsExiredUsingAbsoluteTimeWithLongTTL() 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(System.currentTimeMillis() - 5000);
+      // AET should override any TTL set
+      message.setTimeToLive(60000);
+      message.setText("Test-Message");
+      sender.send(message);
+      sender.close();
+
+      assertEquals(1, queueView.getMessageCount());
+
+      // Now try and get the message
+      AmqpReceiver receiver = session.createReceiver(getTestName());
+      receiver.flow(1);
+      AmqpMessage received = receiver.receive(5, 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());
+      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(System.currentTimeMillis() + 5000);
+      // AET should override any TTL set
+      message.setTimeToLive(10);
+      message.setText("Test-Message");
+      sender.send(message);
+      sender.close();
+
+      Thread.sleep(50);
+
+      assertEquals(1, queueView.getMessageCount());
+
+      // Now try and get the message
+      AmqpReceiver receiver = session.createReceiver(getTestName());
+      receiver.flow(1);
+      AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS);
+      assertNotNull(received);
+
+      assertEquals(0, queueView.getMessagesExpired());
+
+      connection.close();
+   }
+
+   @Test(timeout = 60000)
+   public void testSendMessageThatIsNotExpiredUsingTimeToLive() 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.setTimeToLive(5000);
+      message.setText("Test-Message");
+      sender.send(message);
+      sender.close();
+
+      assertEquals(1, queueView.getMessageCount());
+
+      // Now try and get the message
+      AmqpReceiver receiver = session.createReceiver(getTestName());
+      receiver.flow(1);
+      AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS);
+      assertNotNull(received);
+
+      assertEquals(0, queueView.getMessagesExpired());
+
+      connection.close();
+   }
+
+   @Test(timeout = 60000)
+   public void testSendMessageThenAllowToExpiredUsingTimeToLive() 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.setTimeToLive(10);
+      message.setText("Test-Message");
+      sender.send(message);
+      sender.close();
+
+      Thread.sleep(50);
+
+      assertEquals(1, queueView.getMessageCount());
+
+      // Now try and get the message
+      AmqpReceiver receiver = session.createReceiver(getTestName());
+      receiver.flow(1);
+      AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS);
+      assertNull(received);
+
+      assertEquals(1, queueView.getMessagesExpired());
+
+      connection.close();
+   }
+}

Reply | Threaded
Open this post in threaded view
|

[3/4] activemq-artemis git commit: ARTEMIS-1041 Adjusting when hearders are being parsed

clebertsuconic-2
In reply to this post by clebertsuconic-2
ARTEMIS-1041 Adjusting when hearders are being parsed


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

Branch: refs/heads/master
Commit: 31639782f0ddb31ee32d2d9955420d7ccd183d32
Parents: 8a84b6a
Author: Clebert Suconic <[hidden email]>
Authored: Wed Mar 15 19:22:42 2017 -0400
Committer: Clebert Suconic <[hidden email]>
Committed: Wed Mar 15 19:27:59 2017 -0400

----------------------------------------------------------------------
 .../apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java  | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/31639782/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 56ac1f5..60aae4c 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
@@ -80,6 +80,7 @@ public class AMQPMessage extends RefCountMessage {
       this.data = Unpooled.wrappedBuffer(data);
       this.messageFormat = messageFormat;
       this.bufferValid = true;
+      parseHeaders();
 
    }
 
@@ -897,5 +898,6 @@ public class AMQPMessage extends RefCountMessage {
       record.readBytes(recordArray);
       this.data = Unpooled.wrappedBuffer(recordArray);
       this.bufferValid = true;
+      parseHeaders();
    }
 }

Reply | Threaded
Open this post in threaded view
|

[4/4] activemq-artemis git commit: This closes #1096

clebertsuconic-2
In reply to this post by clebertsuconic-2
This closes #1096


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

Branch: refs/heads/master
Commit: dca124f9aa7477ef651b65ac13393a0a3471dd5d
Parents: 2ba90ef 3163978
Author: Clebert Suconic <[hidden email]>
Authored: Wed Mar 15 19:30:54 2017 -0400
Committer: Clebert Suconic <[hidden email]>
Committed: Wed Mar 15 19:30:54 2017 -0400

----------------------------------------------------------------------
 .../protocol/amqp/broker/AMQPMessage.java       |  15 +-
 .../transport/amqp/client/AmqpMessage.java      |  61 ++++-
 .../amqp/AmqpExpiredMessageTest.java            | 225 +++++++++++++++++++
 3 files changed, 292 insertions(+), 9 deletions(-)
----------------------------------------------------------------------