[
https://issues.apache.org/jira/browse/ARTEMIS-5142?focusedWorklogId=948043&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-948043
]
ASF GitHub Bot logged work on ARTEMIS-5142:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 12/Dec/24 15:27
Start Date: 12/Dec/24 15:27
Worklog Time Spent: 10m
Work Description: 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.
Issue Time Tracking
-------------------
Worklog Id: (was: 948043)
Time Spent: 6h 10m (was: 6h)
> Setting 0 for min/max-expiry-delay not working as expected
> ----------------------------------------------------------
>
> Key: ARTEMIS-5142
> URL: https://issues.apache.org/jira/browse/ARTEMIS-5142
> Project: ActiveMQ Artemis
> Issue Type: Improvement
> Reporter: Justin Bertram
> Assignee: Justin Bertram
> Priority: Major
> Labels: pull-request-available
> Time Spent: 6h 10m
> Remaining Estimate: 0h
>
> In an attempt to never expire messages I tried setting either
> {{max-expiry-delay}} or {{min-expiry-delay}} to {{0}}. However, this caused
> messages to be expired _immediately_ rather than not expired at. There
> doesn't appear to be any way to categorically prevent incoming messages sent
> to a particular from expiring.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact