/**
  * Produce and send a single message to broker
  * @param int $partition is the target partition, either Topic::PARTITION_UA (unassigned) for automatic partitioning using the topic's partitioner function, or a fixed partition (0..N)
  * @param string $payload is the message payload
  * @param string|null $key is an optional message key, if non-NULL it will be passed to the topic partitioner as well as be sent with the message to the broker and passed on to the consumer.
  */
 public function produce($partition, $payload, $key = null)
 {
     $this->producerTopic->produce($partition, 0, $payload, $key);
 }
Exemplo n.º 2
0
 /**
  * @param array $record
  *
  * @return void
  */
 protected function write(array $record)
 {
     $this->topic->produce(RD_KAFKA_PARTITION_UA, 0, $record['formatted']);
 }
Exemplo n.º 3
0
 /**
  * Produce and send a single message to broker
  * @param $payload is the message payload
  * @param $key is an optional message key, if non-NULL it will be passed to the topic partitioner as well as be sent with the message to the broker and passed on to the consumer.
  * @param int $partition is the target partition, either Topic::PARTITION_UA (unassigned) for automatic partitioning using the topic's partitioner function, or a fixed partition (0..N)
  */
 public function produce($payload, $key = null, $partition = Topic::PARTITION_UA)
 {
     $this->rdKafkaProducerTopic->produce($partition, 0, $payload, $key);
 }
 public function testLogMessage()
 {
     $this->producerTopic->shouldReceive('produce')->with(RD_KAFKA_PARTITION_UA, 0, json_encode(['event' => 'critical alert']))->once();
     $this->monolog->critical(json_encode(['event' => 'critical alert']));
 }