/** * Returns whether this message is expired or not. */ default boolean isExpired() { if (getExpiration() == 0) { return false; } return System.currentTimeMillis() - getExpiration() >= 0; }
/** * @return Returns the message in Map form, useful when encoding to JSON */ default Map<String, Object> toMap() { Map map = toPropertyMap(); map.put("messageID", getMessageID()); Object userID = getUserID(); if (getUserID() != null) { map.put("userID", "ID:" + userID.toString()); } map.put("address", getAddress() == null ? "" : getAddress()); map.put("durable", isDurable()); map.put("expiration", getExpiration()); map.put("timestamp", getTimestamp()); map.put("priority", (int)getPriority()); return map; }
@Override public void copyHeadersAndProperties(final Message msg) { messageID = msg.getMessageID(); address = msg.getAddressSimpleString(); userID = (UUID) msg.getUserID(); type = msg.toCore().getType(); durable = msg.isDurable(); expiration = msg.getExpiration(); timestamp = msg.getTimestamp(); priority = msg.getPriority(); if (msg instanceof CoreMessage) { properties = ((CoreMessage) msg).getTypedProperties(); } }
/** * Returns whether this message is expired or not. */ default boolean isExpired() { if (getExpiration() == 0) { return false; } return System.currentTimeMillis() - getExpiration() >= 0; }
/** * Returns whether this message is expired or not. */ default boolean isExpired() { if (getExpiration() == 0) { return false; } return System.currentTimeMillis() - getExpiration() >= 0; }
/** * Returns whether this message is expired or not. */ default boolean isExpired() { if (getExpiration() == 0) { return false; } return System.currentTimeMillis() - getExpiration() >= 0; }
/** * Returns whether this message is expired or not. */ default boolean isExpired() { if (getExpiration() == 0) { return false; } return System.currentTimeMillis() - getExpiration() >= 0; }
/** * Returns whether this message is expired or not. */ default boolean isExpired() { if (getExpiration() == 0) { return false; } return System.currentTimeMillis() - getExpiration() >= 0; }
/** * Returns whether this message is expired or not. */ default boolean isExpired() { if (getExpiration() == 0) { return false; } return System.currentTimeMillis() - getExpiration() >= 0; }
private void applyExpiryDelay(Message message, SimpleString address) { long expirationOverride = addressSettingsRepository.getMatch(address.toString()).getExpiryDelay(); // A -1 <expiry-delay> means don't do anything if (expirationOverride >= 0) { // only override the exiration on messages where the expiration hasn't been set by the user if (message.getExpiration() == 0) { message.setExpiration(System.currentTimeMillis() + expirationOverride); } } }
/** * @return Returns the message in Map form, useful when encoding to JSON */ default Map<String, Object> toMap() { Map map = toPropertyMap(); map.put("messageID", getMessageID()); Object userID = getUserID(); if (getUserID() != null) { map.put("userID", "ID:" + userID.toString()); } map.put("address", getAddress() == null ? "" : getAddress()); map.put("durable", isDurable()); map.put("expiration", getExpiration()); map.put("timestamp", getTimestamp()); map.put("priority", (int)getPriority()); return map; }
/** * @return Returns the message in Map form, useful when encoding to JSON */ default Map<String, Object> toMap() { Map map = toPropertyMap(); map.put("messageID", getMessageID()); Object userID = getUserID(); if (getUserID() != null) { map.put("userID", "ID:" + userID.toString()); } map.put("address", getAddress() == null ? "" : getAddress()); map.put("durable", isDurable()); map.put("expiration", getExpiration()); map.put("timestamp", getTimestamp()); map.put("priority", (int)getPriority()); return map; }
/** * @return Returns the message in Map form, useful when encoding to JSON */ default Map<String, Object> toMap() { Map map = toPropertyMap(); map.put("messageID", getMessageID()); Object userID = getUserID(); if (getUserID() != null) { map.put("userID", "ID:" + userID.toString()); } map.put("address", getAddress() == null ? "" : getAddress()); map.put("durable", isDurable()); map.put("expiration", getExpiration()); map.put("timestamp", getTimestamp()); map.put("priority", (int)getPriority()); return map; }
@Override public void copyHeadersAndProperties(final Message msg) { messageID = msg.getMessageID(); address = msg.getAddressSimpleString(); userID = (UUID) msg.getUserID(); type = msg.toCore().getType(); durable = msg.isDurable(); expiration = msg.getExpiration(); timestamp = msg.getTimestamp(); priority = msg.getPriority(); if (msg instanceof CoreMessage) { properties = ((CoreMessage) msg).getProperties(); } }
@Override public void copyHeadersAndProperties(final Message msg) { messageID = msg.getMessageID(); address = msg.getAddressSimpleString(); userID = (UUID) msg.getUserID(); type = msg.toCore().getType(); durable = msg.isDurable(); expiration = msg.getExpiration(); timestamp = msg.getTimestamp(); priority = msg.getPriority(); if (msg instanceof CoreMessage) { properties = ((CoreMessage) msg).getProperties(); } }
@Override public void copyHeadersAndProperties(final Message msg) { messageID = msg.getMessageID(); address = msg.getAddressSimpleString(); userID = (UUID) msg.getUserID(); type = msg.toCore().getType(); durable = msg.isDurable(); expiration = msg.getExpiration(); timestamp = msg.getTimestamp(); priority = msg.getPriority(); if (msg instanceof CoreMessage) { properties = ((CoreMessage) msg).getTypedProperties(); } }
@Override public void copyHeadersAndProperties(final Message msg) { messageID = msg.getMessageID(); address = msg.getAddressSimpleString(); userID = (UUID) msg.getUserID(); type = msg.toCore().getType(); durable = msg.isDurable(); expiration = msg.getExpiration(); timestamp = msg.getTimestamp(); priority = msg.getPriority(); if (msg instanceof CoreMessage) { properties = ((CoreMessage) msg).getTypedProperties(); } }
@Override public void copyHeadersAndProperties(final Message msg) { messageID = msg.getMessageID(); address = msg.getAddressSimpleString(); userID = (UUID) msg.getUserID(); type = msg.toCore().getType(); durable = msg.isDurable(); expiration = msg.getExpiration(); timestamp = msg.getTimestamp(); priority = msg.getPriority(); if (msg instanceof CoreMessage) { properties = ((CoreMessage) msg).getTypedProperties(); } }
@Override public void copyHeadersAndProperties(final Message msg) { messageID = msg.getMessageID(); address = msg.getAddressSimpleString(); userID = (UUID) msg.getUserID(); type = msg.toCore().getType(); durable = msg.isDurable(); expiration = msg.getExpiration(); timestamp = msg.getTimestamp(); priority = msg.getPriority(); if (msg instanceof CoreMessage) { properties = ((CoreMessage) msg).getProperties(); } }
@Test public void testExpired() { Message message = new ClientMessageImpl(); Assert.assertEquals(0, message.getExpiration()); Assert.assertFalse(message.isExpired()); message.setExpiration(System.currentTimeMillis() + 1000); Assert.assertFalse(message.isExpired()); message.setExpiration(System.currentTimeMillis() - 1); Assert.assertTrue(message.isExpired()); message.setExpiration(System.currentTimeMillis() - 1000); Assert.assertTrue(message.isExpired()); message.setExpiration(0); Assert.assertFalse(message.isExpired()); }