This commit is contained in:
Clebert Suconic 2021-02-17 15:31:08 -05:00
commit f451c42d22
2 changed files with 17 additions and 0 deletions

View File

@ -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);

View File

@ -992,6 +992,19 @@ public class AMQPMessageTest {
assertTrue(decoded.getExpiration() > System.currentTimeMillis());
}
@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());