hyperf / amqp

MIT License
19 stars 15 forks source link

handling publish subscribe fanout #15

Open xtwoend opened 2 years ago

xtwoend commented 2 years ago

hyperf is awesome framework but i have problem when using amqp on rabbitmq, when i want to use fanout in Publish/Subscribe implementation but when doing queue_declare queue name cannot be null.

/**
 * @Consumer(exchange="broadcast", routingKey="", queue="", name="SubribeMessage", nums=1)
 */
#[Consumer(exchange: 'broadcast', routingKey: '', queue: '', name: "SubribeMessage", nums: 1)]
class SubribeMessage extends ConsumerMessage
{
    protected $type = Type::FANOUT;

    public function consumeMessage($data, AMQPMessage $message): string
    {
        var_dump($data);
        return Result::ACK;
    }
}
 public function setQueue(string $queue): self
    {
        $this->queue = $queue;
        return $this;
    }

    public function getQueue(): string
    {
        return $this->queue;
    }