ARTEMIS-1090 - Message not expired if absolute expiry time is 0 and ttl is set

https://issues.apache.org/jira/browse/ARTEMIS-1090
This commit is contained in:
Andy Taylor 2017-04-03 08:22:51 +01:00 committed by Martyn Taylor
parent 57bae51e85
commit 5529bf150a
2 changed files with 36 additions and 1 deletions

View File

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

View File

@ -124,6 +124,41 @@ public class AmqpExpiredMessageTest extends AmqpClientTestSupport {
connection.close();
}
@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();