File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -274,6 +274,8 @@ public function consume(ExtensionInterface $runtimeExtension = null): void
274
274
case Result::REQUEUE :
275
275
$ consumer ->reject ($ message , true );
276
276
break ;
277
+ case Result::ALREADY_ACKNOWLEDGED :
278
+ break ;
277
279
default :
278
280
throw new \LogicException (sprintf ('Status is not supported: %s ' , $ result ));
279
281
}
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ class Result
22
22
*/
23
23
const REQUEUE = Processor::REQUEUE ;
24
24
25
+ const ALREADY_ACKNOWLEDGED = 'enqueue.already_acknowledged ' ;
26
+
25
27
/**
26
28
* @var string
27
29
*/
Original file line number Diff line number Diff line change @@ -470,6 +470,40 @@ public function testShouldRejectMessageIfProcessorReturnSuchStatus()
470
470
$ queueConsumer ->consume ();
471
471
}
472
472
473
+ public function testShouldDoNothingIfProcessorReturnsAlreadyAcknowledged ()
474
+ {
475
+ $ messageMock = $ this ->createMessageMock ();
476
+
477
+ $ subscriptionConsumerMock = new DummySubscriptionConsumer ();
478
+ $ subscriptionConsumerMock ->addMessage ($ messageMock , 'foo_queue ' );
479
+
480
+ $ consumerStub = $ this ->createConsumerStub ('foo_queue ' );
481
+ $ consumerStub
482
+ ->expects ($ this ->never ())
483
+ ->method ('reject ' )
484
+ ;
485
+ $ consumerStub
486
+ ->expects ($ this ->never ())
487
+ ->method ('acknowledge ' )
488
+ ;
489
+
490
+ $ contextStub = $ this ->createContextStub ($ consumerStub );
491
+
492
+ $ processorMock = $ this ->createProcessorMock ();
493
+ $ processorMock
494
+ ->expects ($ this ->once ())
495
+ ->method ('process ' )
496
+ ->with ($ this ->identicalTo ($ messageMock ))
497
+ ->willReturn (Result::ALREADY_ACKNOWLEDGED )
498
+ ;
499
+
500
+ $ queueConsumer = new QueueConsumer ($ contextStub , new BreakCycleExtension (1 ));
501
+ $ queueConsumer ->setFallbackSubscriptionConsumer ($ subscriptionConsumerMock );
502
+ $ queueConsumer ->bind (new NullQueue ('foo_queue ' ), $ processorMock );
503
+
504
+ $ queueConsumer ->consume ();
505
+ }
506
+
473
507
public function testShouldRequeueMessageIfProcessorReturnSuchStatus ()
474
508
{
475
509
$ messageMock = $ this ->createMessageMock ();
You can’t perform that action at this time.
0 commit comments