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

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

                Author: ASF GitHub Bot
            Created on: 24/May/21 19:58
            Start Date: 24/May/21 19:58
    Worklog Time Spent: 10m 
      Work Description: jbertram commented on a change in pull request #3583:
URL: https://github.com/apache/activemq-artemis/pull/3583#discussion_r638236618



##########
File path: 
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java
##########
@@ -151,25 +171,20 @@ public synchronized void addTail(final MessageReference 
ref, final boolean direc
          HolderReference hr = map.get(prop);
 
          if (hr != null) {
-            // We need to overwrite the old ref with the new one and ack the 
old one
-
-            replaceLVQMessage(ref, hr);
-
-            if (isNonDestructive() && hr.isDelivered()) {
-               hr.resetDelivered();
-               // 
--------------------------------------------------------------------------------
-               // If non Destructive, and if a reference was previously 
delivered
-               // we would not be able to receive this message again
-               // unless we reset the iterators
-               // The message is not removed, so we can't actually remove it
-               // a result of this operation is that previously delivered 
messages
-               // will probably be delivered again.
-               // if we ever want to avoid other redeliveries we would have to 
implement a reset or redeliver
-               // operation on the iterator for a single message
-               resetAllIterators();
-               deliverAsync();
-            }
+            if (isNonDestructive() && hr.isInDelivery()) {
+               // if the ref is already being delivered we'll do the replace 
in the postAcknowledge
+               hr.setReplacementRef(ref);
+            } else {
+               // We need to overwrite the old ref with the new one and ack 
the old one
+               replaceLVQMessage(ref, hr);
 
+               if (isNonDestructive() && hr.isDelivered()) {
+                  hr.resetDelivered();
+                  // since we're replacing a ref that was already delivered we 
want to trigger a "special" delivery for this new replacement

Review comment:
       I fixed "special" in the comment.
   
   I didn't change `repeatNextDelivery`. I used "repeat" in the name because it 
serves the same purpose as `repeat` on the `LinkedListIterator` in `QueueImpl`. 
I wanted that to be clear so its easy to see that if the consumer is "busy" we 
just repeat the delivery no matter what.




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

For queries about this service, please contact Infrastructure at:
[email protected]


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

    Worklog Id:     (was: 601366)
    Time Spent: 5h 40m  (was: 5.5h)

> Potential duplicate messages with LVQ + non-destructive
> -------------------------------------------------------
>
>                 Key: ARTEMIS-3285
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3285
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>            Reporter: Justin Bertram
>            Assignee: Justin Bertram
>            Priority: Major
>          Time Spent: 5h 40m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to