[ 
https://issues.apache.org/jira/browse/ARTEMIS-5119?focusedWorklogId=946997&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-946997
 ]

ASF GitHub Bot logged work on ARTEMIS-5119:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 06/Dec/24 09:59
            Start Date: 06/Dec/24 09:59
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on code in PR #5327:
URL: https://github.com/apache/activemq-artemis/pull/5327#discussion_r1872954781


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java:
##########
@@ -2129,36 +2130,85 @@ public void expire(final MessageReference ref) throws 
Exception {
     *           hence no information about delivering statistics should be 
updated. */
    @Override
    public void expire(final MessageReference ref, final ServerConsumer 
consumer, boolean delivering) throws Exception {
-      if (addressSettings.getExpiryAddress() != null) {
-         createExpiryResources();
+      expire(null, ref, consumer, delivering);
+   }
 
-         if (logger.isTraceEnabled()) {
-            logger.trace("moving expired reference {} to address = {} from 
queue={}", ref, addressSettings.getExpiryAddress(), name);
+   private void expire(final Transaction tx, final MessageReference ref, final 
ServerConsumer consumer, boolean delivering) throws Exception {
+      AddressSettings settingsToUse = 
getMessageAddressSettings(ref.getMessage());
+      SimpleString expiryAddress = settingsToUse.getExpiryAddress();
+
+      if (logger.isDebugEnabled()) {
+         logger.debug("expire on {}/{}, consumer={}, expiryAddress={}", 
this.address, this.name, consumer, expiryAddress);
+      }
+
+      if (expiryAddress != null && expiryAddress.length() != 0) {
+         String messageAddress = ref.getMessage().getAddress();
+
+         if (messageAddress == null) {
+            // in the unlikely event where a message does not have an address 
stored on the message itself,
+            // we will get the address from the current queue
+            messageAddress = String.valueOf(getAddress());
          }
+         createExpiryResources(messageAddress, settingsToUse);
 
-         move(null, addressSettings.getExpiryAddress(), null, ref, false, 
AckReason.EXPIRED, consumer, null, delivering);
+         Bindings bindingList = 
postOffice.lookupBindingsForAddress(expiryAddress);
+
+         if (bindingList == null || bindingList.getBindings().isEmpty()) {
+            
ActiveMQServerLogger.LOGGER.errorExpiringReferencesNoBindings(expiryAddress);
+            acknowledge(tx, ref, AckReason.EXPIRED, null, delivering);
+         } else {
+            move(tx, expiryAddress, null, ref, false, AckReason.EXPIRED, 
consumer, null, delivering);
+         }
       } else {
-         logger.trace("expiry is null, just acking expired message for 
reference {} from queue={}", ref, name);
+         if (!printErrorExpiring) {
+            printErrorExpiring = true;
+            // print this only once
+            ActiveMQServerLogger.LOGGER.errorExpiringReferencesNoAddress(name);
+         }
 
-         acknowledge(null, ref, AckReason.EXPIRED, consumer, delivering);
+         acknowledge(tx, ref, AckReason.EXPIRED, consumer, delivering);
       }
 
-      // potentially auto-delete this queue if this expired the last message
-      refCountForConsumers.check();

Review Comment:
   You updated the behaviour a bit, bit it still differs from before in the 
sense that for the combined expire method it only runs the 
refCountForConsumers.check(); if there is a broker message plugin, rather than 
always doing it before for this old expire method (the other old expire method 
only did it if there is a plugin). Was it wrong to always check it in this 
method before, i.e was the other method correct not to do it without a plugin? 
Essentially, why should it need a broker message plugin to do it?





Issue Time Tracking
-------------------

    Worklog Id:     (was: 946997)
    Time Spent: 2h  (was: 1h 50m)

> Messages that expire in store-and-forward (sf-) queues should go to original 
> queue's configured expiry queue
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: ARTEMIS-5119
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5119
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.37.0
>            Reporter: Rakhi Kumari
>            Assignee: Clebert Suconic
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 2.39.0
>
>          Time Spent: 2h
>  Remaining Estimate: 0h
>
> When messages expire in the store-and-forward queues, they go to the 
> store-and-forward queue's expiry queue. It would be better if the messages go 
> to the original queue's expiry queue.



--
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


Reply via email to