You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2021/02/17 20:31:16 UTC
[activemq-artemis] branch master updated: ARTEMIS-3118 Fix the
expiration on converting from AMQP to core
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/master by this push:
new ab7058a ARTEMIS-3118 Fix the expiration on converting from AMQP to core
new f451c42 This closes #3457
ab7058a is described below
commit ab7058ac7531c3522bd85dd25b003ea765d45c74
Author: Domenico Francesco Bruscino <br...@apache.org>
AuthorDate: Wed Feb 17 17:31:04 2021 +0100
ARTEMIS-3118 Fix the expiration on converting from AMQP to core
Initialize the JMS expiration with the value calculated during the scan
of the AMQP message to avoid a different value for each conversion based
on System.currentTimeMillis() and ttl.
---
.../artemis/protocol/amqp/converter/AmqpCoreConverter.java | 4 ++++
.../artemis/protocol/amqp/broker/AMQPMessageTest.java | 13 +++++++++++++
2 files changed, 17 insertions(+)
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/AmqpCoreConverter.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/AmqpCoreConverter.java
index e93a7bb..8071dbe 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/AmqpCoreConverter.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/AmqpCoreConverter.java
@@ -210,6 +210,10 @@ public class AmqpCoreConverter {
throw new RuntimeException("Unexpected body type: " + body.getClass());
}
+ // Initialize the JMS expiration with the value calculated during the scan of the AMQP message
+ // to avoid a different value for each conversion based on System.currentTimeMillis() and ttl.
+ result.setJMSExpiration(message.getExpiration());
+
processHeader(result, header);
processMessageAnnotations(result, annotations);
processApplicationProperties(result, applicationProperties);
diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessageTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessageTest.java
index 487a19a..3eb4d23 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessageTest.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessageTest.java
@@ -993,6 +993,19 @@ public class AMQPMessageTest {
}
@Test
+ public void testGetExpirationFromCoreMessageUsingTTL() {
+ final long ttl = 100000;
+
+ MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
+ protonMessage.setHeader(new Header());
+ protonMessage.setTtl(ttl);
+ AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage);
+
+ ICoreMessage coreMessage = decoded.toCore();
+ assertEquals(decoded.getExpiration(), coreMessage.getExpiration());
+ }
+
+ @Test
public void testGetExpirationFromMessageUsingAbsoluteExpiration() {
final Date expirationTime = new Date(System.currentTimeMillis());