public function consumeAction() { $queue = $this->queues->create($this->getRequest()->getParam('queue')); $this->consumer->consume($queue, ['max-runtime' => $this->getRequest()->getParam('max-runtime', PHP_INT_MAX), 'stop-on-error' => $this->getRequest()->getParam('stop-on-failure', false), 'max-messages' => $this->getRequest()->getParam('max-messages', null), 'stop-when-empty' => $this->getRequest()->getParam('stop-when-empty', false)]); }
use Bernard\Router\SimpleRouter; use Bernard\Consumer; use Bernard\QueueFactory\PersistentFactory; use Bernard\Message\DefaultMessage; use Bernard\Producer; use Bernard\Serializer; use Symfony\Component\EventDispatcher\EventDispatcher; class CDashSubmissionService { public function doSubmit(DefaultMessage $message) { global $CDASH_BASE_URL, $CDASH_REMOTE_ADDR; // Since this could be running on a remote machine, spoof the IP // to appear as the IP that actually submitted the build $CDASH_REMOTE_ADDR = $message['submission_ip']; $result = do_submit($message['buildsubmissionid'], $message['projectid'], $message['expected_md5'], $message['do_checksum'], $message['submission_id']); // If the submission didn't explicitly fail, delete the submission XML to avoid // duplicate submissions if ($result !== false) { $client = new GuzzleHttp\Client(); $response = $client->request('DELETE', $CDASH_BASE_URL . '/api/v1/deleteBuildSubmissionXml.php', array('query' => array('buildsubmissionid' => $message['buildsubmissiondid']))); } } } $router = new SimpleRouter(); $router->add('DoSubmit', new CDashSubmissionService()); $factory = new PersistentFactory($CDASH_BERNARD_DRIVER, new Serializer()); // Create a Consumer and start the loop. $consumer = new Consumer($router, new EventDispatcher()); $consumer->consume($factory->create('do-submit'));
/** * {@inheritdoc} */ public function consume($queue, array $options = []) { $queue = $this->queueFactory->create($queue); $this->consumer->consume($queue, $options); }