Skip to content

Commit 5ce0833

Browse files
ktheragefabpot
authored andcommitted
[Messenger] Add new messenger:count command that return a list of transports with their "to be processed" message count.
1 parent 725b56c commit 5ce0833

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
use Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpTransportFactory;
109109
use Symfony\Component\Messenger\Bridge\Beanstalkd\Transport\BeanstalkdTransportFactory;
110110
use Symfony\Component\Messenger\Bridge\Redis\Transport\RedisTransportFactory;
111+
use Symfony\Component\Messenger\Command\StatsCommand;
111112
use Symfony\Component\Messenger\Handler\BatchHandlerInterface;
112113
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
113114
use Symfony\Component\Messenger\MessageBus;
@@ -503,6 +504,7 @@ public function load(array $configs, ContainerBuilder $container)
503504
$this->registerMessengerConfiguration($config['messenger'], $container, $loader, $config['validation']);
504505
} else {
505506
$container->removeDefinition('console.command.messenger_consume_messages');
507+
$container->removeDefinition('console.command.messenger_stats');
506508
$container->removeDefinition('console.command.messenger_debug');
507509
$container->removeDefinition('console.command.messenger_stop_workers');
508510
$container->removeDefinition('console.command.messenger_setup_transports');
@@ -1966,6 +1968,10 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
19661968
throw new LogicException('Messenger support cannot be enabled as the Messenger component is not installed. Try running "composer require symfony/messenger".');
19671969
}
19681970

1971+
if (!class_exists(StatsCommand::class)) {
1972+
$container->removeDefinition('console.command.messenger_stats');
1973+
}
1974+
19691975
$loader->load('messenger.php');
19701976

19711977
if (!interface_exists(DenormalizerInterface::class)) {

Resources/config/console.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
use Symfony\Component\Console\EventListener\ErrorListener;
4343
use Symfony\Component\Dotenv\Command\DebugCommand as DotenvDebugCommand;
4444
use Symfony\Component\Messenger\Command\ConsumeMessagesCommand;
45+
use Symfony\Component\Messenger\Command\StatsCommand;
4546
use Symfony\Component\Messenger\Command\DebugCommand;
4647
use Symfony\Component\Messenger\Command\FailedMessagesRemoveCommand;
4748
use Symfony\Component\Messenger\Command\FailedMessagesRetryCommand;
@@ -206,6 +207,13 @@
206207
])
207208
->tag('console.command')
208209

210+
->set('console.command.messenger_stats', StatsCommand::class)
211+
->args([
212+
service('messenger.receiver_locator'),
213+
abstract_arg('Receivers names'),
214+
])
215+
->tag('console.command')
216+
209217
->set('console.command.router_debug', RouterDebugCommand::class)
210218
->args([
211219
service('router'),
@@ -334,5 +342,5 @@
334342
service('secrets.local_vault')->ignoreOnInvalid(),
335343
])
336344
->tag('console.command')
337-
;
345+
;
338346
};

0 commit comments

Comments
 (0)