Example #1
0
 /**
  * @return Queue
  */
 private function getQueue()
 {
     if (null === $this->queue) {
         $this->queue = $this->consumer->newQueue();
     }
     return $this->queue;
 }
Example #2
0
 /**
  * @param string $topic
  * @param ConsumerConfiguration|null $consumerConfiguration
  * @return ConsumerTopicFacade
  */
 public function createConsumerTopicFacade($topic, ConsumerConfiguration $consumerConfiguration = null)
 {
     if (null === $consumerConfiguration) {
         $consumerConfiguration = new ConsumerConfiguration();
     }
     if (null === $this->rdKafkaConsumer) {
         $this->rdKafkaConsumer = $this->createConsumer();
     }
     return new ConsumerTopicFacade($this->rdKafkaConsumer->newTopic($topic, $consumerConfiguration->toRdKafkaTopicConfig()));
 }
Example #3
0
 /**
  *
  * @param ClusterMetadataInterface|null $clusterMetadata
  * @param \RdKafka\Conf|null            $config
  */
 public function __construct(ClusterMetadataInterface $clusterMetadata = null, \RdKafka\Conf $config = null)
 {
     if (empty($config)) {
         $config = new \RdKafka\Conf();
     }
     if (!empty($clusterMetadata)) {
         $brokers = $clusterMetadata->getBrokers();
         $brokers = array_map(function ($broker) {
             return sprintf('%s:%d', $broker['host'], $broker['port']);
         }, $brokers);
         $config->set('metadata.broker.list', implode(',', $brokers));
     }
     parent::__construct($config);
 }
 /**
  * @return ConsumerTopic
  */
 private function buildConsumerTopic()
 {
     $consumer = new Consumer();
     $consumer->addBrokers(self::BROKER);
     return $consumer->newTopic(self::TOPIC);
 }