Open FarzadForuozanfar opened 5 months ago
<?php declare(strict_types=1); namespace App\Amqp\Producer; use Hyperf\Amqp\Message\ProducerMessage; use Hyperf\Amqp\Annotation\Producer; /** * @Producer(exchange="ex.priority", routingKey="priority", exchangeType="direct", durable=true) */ class SmsProducer extends ProducerMessage { public function __construct($priority, $message) { $this->payload = $message; $this->setRoutingKey('priority' . $priority); $this->setExchange('ex.priority.' . $priority); $this->setType('direct'); } public function getExchange(): string { return 'ex.priority.' . $this->getRoutingKeySuffix(); } public function getRoutingKey(): string { return 'priority' . $this->getRoutingKeySuffix(); } public function getQueue(): string { return 'q.priority.' . $this->getRoutingKeySuffix(); } private function getRoutingKeySuffix(): string { return substr($this->routingKey, -1); } public function buildExchange(): void { // return (new ExchangeBuilder()) // ->withName($this->getExchange()) // ->withType('direct') // ->withDurable(true); } public function buildQueue(): void { // return (new QueueBuilder()) // ->withName($this->getQueue()) // ->withDurable(true); } }
You can try removed annotation #[Producer] from you class.
#[Producer]