Created
May 11, 2020 09:21
-
-
Save slischka/8dfa71435118bd348a512029f999bc2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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