File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -95,17 +95,21 @@ public function consume(int $timeout = 0): void
9595 $ redeliveryDelay = $ this ->getRedeliveryDelay () / 1000 ; // milliseconds to seconds
9696
9797 $ currentQueueNames = [];
98+ $ queueConsumed = false ;
9899 while (true ) {
99100 if (empty ($ currentQueueNames )) {
100101 $ currentQueueNames = $ queueNames ;
102+ $ queueConsumed = false ;
101103 }
102104
103105 $ this ->removeExpiredMessages ();
104106 $ this ->redeliverMessages ();
105107
106108 if ($ message = $ this ->fetchMessage ($ currentQueueNames , $ redeliveryDelay )) {
109+ $ queueConsumed = true ;
110+
107111 /**
108- * @var DbalConsumer
112+ * @var DbalConsumer $consumer
109113 * @var callable $callback
110114 */
111115 [$ consumer , $ callback ] = $ this ->subscribers [$ message ->getQueue ()];
@@ -118,7 +122,9 @@ public function consume(int $timeout = 0): void
118122 } else {
119123 $ currentQueueNames = [];
120124
121- usleep ($ this ->getPollingInterval () * 1000 );
125+ if (!$ queueConsumed ) {
126+ usleep ($ this ->getPollingInterval () * 1000 );
127+ }
122128 }
123129
124130 if ($ timeout && microtime (true ) >= $ now + $ timeout ) {
You can’t perform that action at this time.
0 commit comments