contributte / rabbitmq

🐰 RabbitMQ (AMQP, STOMP, MQTT) using BunnyPHP for Nette Framework (@nette).
https://contributte.org/packages/contributte/rabbitmq.html
MIT License
24 stars 25 forks source link

Improve StaticConsumer behavior when queue is empty #3

Closed pavelkovar closed 7 years ago

pavelkovar commented 7 years ago

Current static consumer impl calls consume callback even when queue is empty. This behavior causes TypeError exception when consumer implements IConsumer interface.

TypeError: Argument 1 passed to App\Consumer::consume() must be an instance of Bunny\Message, null given in /var/www/project/app/Consumer.php:62
Stack trace:
#0 [internal function]: App\Consumer->consume(NULL)
#1 /var/www/project/vendor/gamee/nette-rabbitmq/src/Consumer/Consumer.php(99): call_user_func(Array, NULL)
#2 /var/www/project/vendor/gamee/nette-rabbitmq/src/Console/Command/StaticConsumerCommand.php(45): Gamee\RabbitMQ\Consumer\Consumer->consumeSpecifiedAmountOfMessages(1)
#3 /var/www/project/vendor/symfony/console/Command/Command.php(264): Gamee\RabbitMQ\Console\Command\StaticConsumerCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /var/www/project/vendor/symfony/console/Application.php(869): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/project/vendor/symfony/console/Application.php(223): Symfony\Component\Console\Application->doRunCommand(Object(Gamee\RabbitMQ\Console\Command\StaticConsumerCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/project/vendor/symfony/console/Application.php(130): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/project/bin/console(5): Symfony\Component\Console\Application->run()
#8 {main}
paveljanda commented 7 years ago

Thanks a lot, your approach is much better.