This commit is contained in:
2021-01-12 17:36:53 +08:00
parent 28eaa54f57
commit 2c77e30ca2
+15 -13
View File
@@ -118,21 +118,23 @@ class Kafka extends \Snowflake\Process\Process
*/
protected function handlerExecute($topic, $message)
{
try {
$topic = str_replace('-', '_', $topic);
go(function () use ($topic, $message) {
try {
$topic = str_replace('-', '_', $topic);
$namespace = 'App\\Kafka\\' . ucfirst($topic) . 'Consumer';
if (!class_exists($namespace)) {
return;
$namespace = 'App\\Kafka\\' . ucfirst($topic) . 'Consumer';
if (!class_exists($namespace)) {
return;
}
$class = Snowflake::createObject($namespace);
if (!($class instanceof ConsumerInterface)) {
return;
}
$class->onHandler(new Struct($topic, $message));
} catch (Throwable $exception) {
$this->application->error($exception->getMessage());
}
$class = Snowflake::createObject($namespace);
if (!($class instanceof ConsumerInterface)) {
return;
}
$class->onHandler(new Struct($topic, $message));
} catch (Throwable $exception) {
$this->application->error($exception->getMessage());
}
});
}