This commit is contained in:
2020-10-26 17:23:22 +08:00
parent 80d7974842
commit a6274261a9
2 changed files with 12 additions and 20 deletions
-1
View File
@@ -112,7 +112,6 @@ class Kafka extends \Snowflake\Process\Process
protected function handlerExecute($topic, $part, $message) protected function handlerExecute($topic, $part, $message)
{ {
try { try {
var_dump($message);
$namespace = 'App\\Kafka\\' . ucfirst($topic) . 'Consumer'; $namespace = 'App\\Kafka\\' . ucfirst($topic) . 'Consumer';
if (!class_exists($namespace)) { if (!class_exists($namespace)) {
return; return;
+12 -19
View File
@@ -4,21 +4,18 @@
namespace Kafka; namespace Kafka;
use RdKafka\Message;
class Struct class Struct
{ {
public $offset; public int $offset;
public $part; public Message $message;
public $topic; public string $topic;
public $crc;
public $magic;
public $attr;
public $timestamp;
public $key;
public $value;
public string $value;
public string $part;
/** /**
* Struct constructor. * Struct constructor.
@@ -26,17 +23,13 @@ class Struct
* @param $part * @param $part
* @param $message * @param $message
*/ */
public function __construct($topic, $part, $message) public function __construct($topic, $part,Message $message)
{ {
$this->topic = $topic; $this->topic = $topic;
$this->offset = $message['offset']; $this->offset = $message->offset;
$this->part = $part; $this->part = $message->partition;
$this->crc = $message['message']['crc']; $this->message = $message;
$this->magic = $message['message']['magic']; $this->value = $message->payload;
$this->attr = $message['message']['attr'];
$this->timestamp = $message['message']['timestamp'];
$this->key = $message['message']['key'];
$this->value = $message['message']['value'];
} }
} }