Skip to content

Commit d72bc2c

Browse files
committed
[consumption] Do not print "Switch to queue xxx" if queue the same.
1 parent eb5cbf8 commit d72bc2c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/enqueue/Consumption/QueueConsumer.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,16 @@ public function consume(ExtensionInterface $runtimeExtension = null)
121121
$logger = $context->getLogger() ?: new NullLogger();
122122
$logger->info('Start consuming');
123123

124+
/** @var Queue|null $previousQueue */
125+
$previousQueue = null;
126+
124127
while (true) {
125128
try {
126129
/** @var Queue $queue */
127130
foreach ($this->boundProcessors as list($queue, $processor)) {
128-
$logger->debug(sprintf('Switch to a queue %s', $queue->getQueueName()));
131+
if (false == $previousQueue || $previousQueue->getQueueName() != $queue->getQueueName()) {
132+
$logger->debug(sprintf('Switch to a queue %s', $queue->getQueueName()));
133+
}
129134

130135
$messageConsumer = $messageConsumers[$queue->getQueueName()];
131136

@@ -136,6 +141,8 @@ public function consume(ExtensionInterface $runtimeExtension = null)
136141
$context->setPsrProcessor($processor);
137142

138143
$this->doConsume($extension, $context);
144+
145+
$previousQueue = $queue;
139146
}
140147
} catch (ConsumptionInterruptedException $e) {
141148
$logger->info(sprintf('Consuming interrupted'));
@@ -215,7 +222,7 @@ protected function doConsume(ExtensionInterface $extension, Context $context)
215222

216223
$extension->onPostReceived($context);
217224
} else {
218-
$logger->info(sprintf('Idle'));
225+
$logger->debug(sprintf('Idle'));
219226

220227
usleep($this->idleMicroseconds);
221228
$extension->onIdle($context);

0 commit comments

Comments
 (0)