Skip to content

Commit

Permalink
不再使用BaseInjectValue作为注解属性值
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Oct 23, 2023
1 parent 168f0ae commit 901cf8c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 47 deletions.
39 changes: 0 additions & 39 deletions src/Components/kafka/example/Annotation/GetGroupId.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
use Imi\Kafka\Annotation\Consumer;
use Imi\Kafka\Base\BaseConsumer;
use Imi\Redis\Redis;
use KafkaApp\Annotation\GetGroupId;
use longlang\phpkafka\Consumer\ConsumeMessage;

/**
* @Bean("TestConsumer")
* @Bean("TestConsumerSwoole")
*
* @Consumer(topic="queue-imi-1", groupId=@GetGroupId)
* @Consumer(topic="queue-imi-1", groupId="test-consumer-swoole")
*/
class TestConsumer extends BaseConsumer
class TestConsumerSwoole extends BaseConsumer
{
/**
* 消费任务
Expand Down
29 changes: 29 additions & 0 deletions src/Components/kafka/example/Kafka/Test/TestConsumerWorkerman.php
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());
}
}
4 changes: 2 additions & 2 deletions src/Components/kafka/example/Process/SwooleTestProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
class SwooleTestProcess extends BaseProcess
{
/**
* @Inject("TestConsumer")
* @Inject("TestConsumerSwoole")
*
* @var \KafkaApp\Kafka\Test\TestConsumer
* @var \KafkaApp\Kafka\Test\TestConsumerSwoole
*/
protected $testConsumer;

Expand Down
4 changes: 2 additions & 2 deletions src/Components/kafka/example/Process/WorkermanTestProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
class WorkermanTestProcess extends BaseProcess
{
/**
* @Inject("TestConsumer")
* @Inject("TestConsumerWorkerman")
*
* @var \KafkaApp\Kafka\Test\TestConsumer
* @var \KafkaApp\Kafka\Test\TestConsumerWorkerman
*/
protected $testConsumer;

Expand Down

0 comments on commit 901cf8c

Please sign in to comment.