-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
36 additions
and
47 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Components/kafka/example/Kafka/Test/TestConsumerWorkerman.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KafkaApp\Kafka\Test; | ||
|
||
use Imi\Bean\Annotation\Bean; | ||
use Imi\Kafka\Annotation\Consumer; | ||
use Imi\Kafka\Base\BaseConsumer; | ||
use Imi\Redis\Redis; | ||
use longlang\phpkafka\Consumer\ConsumeMessage; | ||
|
||
/** | ||
* @Bean("TestConsumerWorkerman") | ||
* | ||
* @Consumer(topic="queue-imi-1", groupId="test-consumer-workerman") | ||
*/ | ||
class TestConsumerWorkerman extends BaseConsumer | ||
{ | ||
/** | ||
* 消费任务 | ||
*/ | ||
protected function consume(ConsumeMessage $message): void | ||
{ | ||
$data = json_decode($message->getValue(), true); | ||
var_dump(__CLASS__, $message->getValue()); | ||
Redis::set('imi-kafka:consume:1:' . $data['memberId'], $message->getValue()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters