Skip to content

Instantly share code, notes, and snippets.

@slischka
Created May 11, 2020 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slischka/8dfa71435118bd348a512029f999bc2f to your computer and use it in GitHub Desktop.
Save slischka/8dfa71435118bd348a512029f999bc2f to your computer and use it in GitHub Desktop.
<?php declare(strict_types = 1);
namespace Fapi\RabbitMQ;
use Gamee\RabbitMQ\Consumer\ConsumerFactory;
use Nette\DI\Container;
class ConsumerRunner
{
/** @var Container */
private $container;
public function __construct(Container $container)
{
$this->container = $container;
}
public function run(string $consumerServiceName, int $messagesToConsume, ?int $maxRuntime = null): int
{
/** @var ConsumerFactory $consumerFactory */
$consumerFactory = $this->container->getByType(ConsumerFactory::class);
$consumer = $consumerFactory->getConsumer($consumerServiceName);
$consumer->consume($maxRuntime, $messagesToConsume);
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment