gemmellr commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1882331195
##########
artemis-server/src/main/resources/schema/artemis-configuration.xsd:
##########
@@ -3871,6 +3871,14 @@
</xsd:annotation>
</xsd:element>
+ <xsd:element name="never-expire" type="xsd:boolean" default="false"
maxOccurs="1" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ Overrides the expiration time for all messages so that they
never expire. "-1" disables this setting.
Review Comment:
This bit needs replaced:
"-1" disables this setting.
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java:
##########
@@ -1355,28 +1355,42 @@ private RoutingStatus maybeSendToDLA(final Message
message,
return status;
}
- // HORNETQ-1029
- private static void applyExpiryDelay(Message message, AddressSettings
settings) {
+ protected static void applyExpiryDelay(Message message, AddressSettings
settings) {
long expirationOverride = settings.getExpiryDelay();
- // A -1 <expiry-delay> means don't do anything
- if (expirationOverride >= 0) {
- // only override the expiration on messages where the expiration
hasn't been set by the user
+ if (settings.getNeverExpire()) {
+ if (message.getExpiration() != 0) {
+ message.setExpiration(0);
+ }
+ } else if (expirationOverride >= 0) {
+ // A -1 <expiry-delay> means don't do anything
if (message.getExpiration() == 0) {
- message.setExpiration(System.currentTimeMillis() +
expirationOverride);
+ // only override the expiration on messages where the expiration
hasn't been set by the user
+ message.setExpiration(getExpirationToSet(expirationOverride));
}
} else {
long minExpiration = settings.getMinExpiryDelay();
long maxExpiration = settings.getMaxExpiryDelay();
- if (maxExpiration != AddressSettings.DEFAULT_MAX_EXPIRY_DELAY &&
(message.getExpiration() == 0 || message.getExpiration() >
(System.currentTimeMillis() + maxExpiration))) {
- message.setExpiration(System.currentTimeMillis() + maxExpiration);
+ if (message.getExpiration() == 0) {
+ // if the incoming message has NO expiration then apply the max if
set and if not set then apply the min if set
+ if (maxExpiration != AddressSettings.DEFAULT_MAX_EXPIRY_DELAY) {
+ message.setExpiration(getExpirationToSet(maxExpiration));
+ } else if (minExpiration !=
AddressSettings.DEFAULT_MIN_EXPIRY_DELAY) {
+ message.setExpiration(getExpirationToSet(minExpiration));
+ }
+ } else if (maxExpiration != AddressSettings.DEFAULT_MAX_EXPIRY_DELAY
&& message.getExpiration() >= (System.currentTimeMillis() + maxExpiration)) {
Review Comment:
If not special casing 0 to unset expiration, can go back to > rather than
>= here. No need to change it if its equal.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact