jeanouii commented on code in PR #1616:
URL: https://github.com/apache/activemq/pull/1616#discussion_r2709419792
##########
activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java:
##########
@@ -771,6 +778,9 @@ void clearMessagesInProgress() {
// ensure unconsumed are rolledback up front as they may
get redelivered to another consumer
List<MessageDispatch> list =
unconsumedMessages.removeAll();
if (!this.info.isBrowser()) {
+ if (session.isTransacted()) {
+
capturePrefetchedMessagesForDuplicateSuppression(list);
Review Comment:
@cshannon you are totally correct. There is no need to iterate twice. Good
catch!
Your proposal works fully.
We could probably even simply the method like this
```
private void capturePrefetchedMessagesForDuplicateSuppression(final
MessageDispatch pending) {
if (pending.getMessage() == null) return; // nothing to do
if (previouslyDeliveredMessages == null) {
previouslyDeliveredMessages = new
PreviouslyDeliveredMap<>(session.getTransactionContext().getTransactionId());
}
previouslyDeliveredMessages.put(pending.getMessage().getMessageId(), new
PreviouslyDelivered(pending, false, true));
LOG.trace("{} tracking existing transacted {} prefetched ({})",
getConsumerId(), previouslyDeliveredMessages.transactionId, pending);
}
```
--
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