jeantil commented on code in PR #2416:
URL: https://github.com/apache/james-project/pull/2416#discussion_r1768433580


##########
server/queue/queue-api/src/test/java/org/apache/james/queue/api/MailQueueContract.java:
##########
@@ -526,22 +533,35 @@ default void 
concurrentEnqueueDequeueWithAckNackShouldNotFail() throws Exception
         int operationCount = 15;
         int totalDequeuedMessages = 50;
         LinkedBlockingDeque<MailQueue.MailQueueItem> deque = new 
LinkedBlockingDeque<>();
+        var mailStates = new ConcurrentHashMap<String, EnqueueDequeueSteps>();
         
Flux.from(testee.deQueue()).subscribeOn(SCHEDULER).doOnNext(deque::addFirst).subscribe();
         ConcurrentTestRunner.builder()
             .operation((threadNumber, step) -> {
                 if (step % 3 == 0) {
+                    String name = "name" + threadNumber + "-" + step;
+
                     testee.enQueue(defaultMail()
-                        .name("name" + threadNumber + "-" + step)
+                        .name(name)
                         .build());
-                }
-                if (step % 3 == 1) {
-                    MailQueue.MailQueueItem mailQueueItem = deque.takeLast();
-                    
mailQueueItem.done(MailQueue.MailQueueItem.CompletionStatus.RETRY);
-                }
-                if (step % 3 == 2) {
+                    mailStates.put(name, EnqueueDequeueSteps.RETRY);
+                } else {
                     MailQueue.MailQueueItem mailQueueItem = deque.takeLast();
-                    dequeuedMails.add(mailQueueItem.getMail());
-                    
mailQueueItem.done(MailQueue.MailQueueItem.CompletionStatus.SUCCESS);
+                    var name = mailQueueItem.getMail().getName();

Review Comment:
   For this test what we want is to : 
   enqueue->retry->success each mail
   in the previous implementation since there was no tracking of the state of a 
specific mail it could result in a mail getting retried twice once another got 
success right away. 
   Since the pulsar mailqueue has a dead letter policy that puts a message in 
dead letter after 1 retry, retrying a message more than once results in that 
message never being dequeable again. This in turn means the test woud block and 
timeout.



-- 
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: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to