diff --git a/doc/base/version/2.1-3.0.md b/doc/base/version/2.1-3.0.md index a8cee4bb74..09d42b9751 100644 --- a/doc/base/version/2.1-3.0.md +++ b/doc/base/version/2.1-3.0.md @@ -12,6 +12,6 @@ * 连接配置项有所增改,参考 [连接配置项](https://doc.imiphp.com/v3.0/components/mq/amqp.html#%E8%BF%9E%E6%8E%A5%E9%85%8D%E7%BD%AE%E9%A1%B9) -* 废弃 `Imi\AMQP\Swoole\AMQPSwooleConnection` 客户端类 +* `Imi\AMQP\Annotation\Connection` 注解类的连接配置全部废弃,只保留 `poolName` -* 废弃 `Imi\AMQP\Annotation\Connection` 注解类 +* 废弃 `Imi\AMQP\Swoole\AMQPSwooleConnection` 客户端类 diff --git a/src/Components/amqp/src/Annotation/Connection.php b/src/Components/amqp/src/Annotation/Connection.php index 486fea8e24..565bf88b9b 100644 --- a/src/Components/amqp/src/Annotation/Connection.php +++ b/src/Components/amqp/src/Annotation/Connection.php @@ -13,23 +13,7 @@ * * @Target({"CLASS"}) * - * @property string|null $poolName 连接池名称 - * @property string $host 主机 - * @property int $port 端口 - * @property string $user 用户名 - * @property string $password 密码 - * @property string $vhost - * @property bool $insist - * @property string $loginMethod - * @property null $loginResponse - * @property string $locale - * @property float $connectionTimeout 连接超时 - * @property float $readWriteTimeout 读写超时 - * @property null $context 上下文 - * @property bool $keepalive - * @property int $heartbeat 心跳时间 - * @property float $channelRpcTimeout 频道 RPC 超时时间 - * @property string|null $sslProtocol ssl 协议 + * @property string|null $poolName 连接池名称 */ #[\Attribute(\Attribute::TARGET_CLASS)] class Connection extends Base @@ -39,30 +23,9 @@ class Connection extends Base */ protected ?string $defaultFieldName = 'poolName'; - /** - * @param null $loginResponse - * @param null $context - */ public function __construct( ?array $__data = null, - ?string $poolName = null, - string $host = '', - int $port = 0, - string $user = '', - #[\SensitiveParameter] - string $password = '', - string $vhost = '/', - bool $insist = false, - string $loginMethod = 'AMQPLAIN', - $loginResponse = null, - string $locale = 'en_US', - float $connectionTimeout = 3.0, - float $readWriteTimeout = 3.0, - $context = null, - bool $keepalive = false, - int $heartbeat = 0, - float $channelRpcTimeout = 0.0, - ?string $sslProtocol = null + ?string $poolName = null ) { parent::__construct(...\func_get_args()); } diff --git a/src/Components/amqp/src/Base/Traits/TAMQP.php b/src/Components/amqp/src/Base/Traits/TAMQP.php index 53e47f6a6f..1000c674e4 100644 --- a/src/Components/amqp/src/Base/Traits/TAMQP.php +++ b/src/Components/amqp/src/Base/Traits/TAMQP.php @@ -96,47 +96,7 @@ protected function initConfig(): void */ protected function getConnection(): AbstractConnection { - $poolName = null; - if (null === $this->poolName) - { - $connectionByPool = false; - $connectionAnnotation = $this->connectionAnnotation; - if ($connectionAnnotation) - { - if (null === $connectionAnnotation->poolName) - { - if (!(null !== $connectionAnnotation->host && null !== $connectionAnnotation->port && null !== $connectionAnnotation->user && null !== $connectionAnnotation->password)) - { - $connectionByPool = true; - } - } - else - { - $connectionByPool = true; - } - } - else - { - $connectionByPool = true; - } - if ($connectionByPool) - { - $poolName = $connectionAnnotation->poolName ?? $this->amqp->getDefaultPoolName(); - } - } - else - { - $connectionByPool = true; - $poolName = $this->poolName; - } - if ($connectionByPool || $poolName) - { - return AMQPPool::getInstance($poolName); - } - else - { - throw new \RuntimeException('Connection poolName must be set'); - } + return AMQPPool::getInstance($this->poolName ?? $this->connectionAnnotation->poolName ?? null); } /**