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
95
95
$ redeliveryDelay = $ this ->getRedeliveryDelay () / 1000 ; // milliseconds to seconds
96
96
97
97
$ currentQueueNames = [];
98
+ $ queueConsumed = false ;
98
99
while (true ) {
99
100
if (empty ($ currentQueueNames )) {
100
101
$ currentQueueNames = $ queueNames ;
102
+ $ queueConsumed = false ;
101
103
}
102
104
103
105
$ this ->removeExpiredMessages ();
104
106
$ this ->redeliverMessages ();
105
107
106
108
if ($ message = $ this ->fetchMessage ($ currentQueueNames , $ redeliveryDelay )) {
109
+ $ queueConsumed = true ;
110
+
107
111
/**
108
- * @var DbalConsumer
112
+ * @var DbalConsumer $consumer
109
113
* @var callable $callback
110
114
*/
111
115
[$ consumer , $ callback ] = $ this ->subscribers [$ message ->getQueue ()];
@@ -118,7 +122,9 @@ public function consume(int $timeout = 0): void
118
122
} else {
119
123
$ currentQueueNames = [];
120
124
121
- usleep ($ this ->getPollingInterval () * 1000 );
125
+ if (!$ queueConsumed ) {
126
+ usleep ($ this ->getPollingInterval () * 1000 );
127
+ }
122
128
}
123
129
124
130
if ($ timeout && microtime (true ) >= $ now + $ timeout ) {
You can’t perform that action at this time.
0 commit comments